parent
cc7c334d73
commit
1a3dcb215e
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "coordsbuffer.h"
|
||||
|
||||
void CoordsBuffer::clear()
|
||||
{
|
||||
m_destRects.reset();
|
||||
m_srcRects.reset();
|
||||
m_textureCoords.clear();
|
||||
m_vertexCoords.clear();
|
||||
m_updateCache = true;
|
||||
}
|
||||
|
||||
void CoordsBuffer::addRect(const Rect& dest)
|
||||
{
|
||||
m_destRects << dest;
|
||||
m_updateCache = true;
|
||||
}
|
||||
|
||||
void CoordsBuffer::addRect(const Rect& dest, const Rect& src)
|
||||
{
|
||||
m_destRects << dest;
|
||||
m_srcRects << src;
|
||||
m_updateCache = true;
|
||||
}
|
||||
|
||||
void CoordsBuffer::addBoudingRect(const Rect& dest, int innerLineWidth)
|
||||
{
|
||||
int left = dest.left();
|
||||
int right = dest.right();
|
||||
int top = dest.top();
|
||||
int bottom = dest.bottom();
|
||||
int width = dest.width();
|
||||
int height = dest.height();
|
||||
int w = innerLineWidth;
|
||||
|
||||
addRect(Rect(left, top, width - w, w)); // top
|
||||
addRect(Rect(right - w + 1, top, w, height - w)); // right
|
||||
addRect(Rect(left + w, bottom - w + 1, width - w, w)); // bottom
|
||||
addRect(Rect(left, top + w, w, height - w)); // left
|
||||
m_updateCache = true;
|
||||
}
|
||||
|
||||
void CoordsBuffer::addRepeatedRects(const Rect& dest, const Rect& src)
|
||||
{
|
||||
if(dest.isEmpty() || src.isEmpty())
|
||||
return;
|
||||
|
||||
Rect virtualDest(0, 0, dest.size());
|
||||
for(int y = 0; y <= virtualDest.height(); y += src.height()) {
|
||||
for(int x = 0; x <= virtualDest.width(); x += src.width()) {
|
||||
Rect partialDest(x, y, src.size());
|
||||
Rect partialSrc(src);
|
||||
|
||||
// partialCoords to screenCoords bottomRight
|
||||
if(partialDest.bottom() > virtualDest.bottom()) {
|
||||
partialSrc.setBottom(partialSrc.bottom() + (virtualDest.bottom() - partialDest.bottom()));
|
||||
partialDest.setBottom(virtualDest.bottom());
|
||||
}
|
||||
if(partialDest.right() > virtualDest.right()) {
|
||||
partialSrc.setRight(partialSrc.right() + (virtualDest.right() - partialDest.right()));
|
||||
partialDest.setRight(virtualDest.right());
|
||||
}
|
||||
|
||||
partialDest.translate(dest.topLeft());
|
||||
m_destRects << partialDest;
|
||||
m_srcRects << partialSrc;
|
||||
}
|
||||
}
|
||||
m_updateCache = true;
|
||||
}
|
||||
|
||||
void CoordsBuffer::cacheVertexArrays()
|
||||
{
|
||||
if(!m_updateCache)
|
||||
return;
|
||||
|
||||
int numDestRects = m_destRects.size();
|
||||
int numSrcRects = m_srcRects.size();
|
||||
m_vertexCoords.clear();
|
||||
m_textureCoords.clear();
|
||||
|
||||
for(int i=0;i<numDestRects;++i) {
|
||||
m_vertexCoords.addRect(m_destRects[i]);
|
||||
if(numSrcRects == numDestRects)
|
||||
m_textureCoords.addRect(m_srcRects[i]);
|
||||
}
|
||||
|
||||
m_updateCache = false;
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef COORDSBUFFER_H
|
||||
#define COORDSBUFFER_H
|
||||
|
||||
#include "vertexarray.h"
|
||||
|
||||
class CoordsBuffer
|
||||
{
|
||||
public:
|
||||
void clear();
|
||||
|
||||
// no texture
|
||||
void addRect(const Rect& dest);
|
||||
void addBoudingRect(const Rect& dest, int innerLineWidth);
|
||||
|
||||
// textured
|
||||
void addRect(const Rect& dest, const Rect& src);
|
||||
void addRepeatedRects(const Rect& dest, const Rect& src);
|
||||
|
||||
void cacheVertexArrays();
|
||||
|
||||
GLfloat *getVertexCoords() const { return m_vertexCoords.vertexArray(); }
|
||||
GLfloat *getTextureCoords() const { return m_textureCoords.vertexArray(); }
|
||||
int getVertexCount() const { return m_vertexCoords.vertexCount(); }
|
||||
|
||||
private:
|
||||
DataBuffer<Rect> m_destRects;
|
||||
DataBuffer<Rect> m_srcRects;
|
||||
VertexArray m_vertexCoords;
|
||||
VertexArray m_textureCoords;
|
||||
Boolean<true> m_updateCache;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "glbuffer.h"
|
||||
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GLBUFFER_H
|
||||
#define GLBUFFER_H
|
||||
|
||||
class GLBuffer
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "textureglyphcache.h"
|
||||
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef TEXTUREGLYPHCACHE_H
|
||||
#define TEXTUREGLYPHCACHE_H
|
||||
|
||||
class TextureGlyphCache
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef VERTEXARRAY_H
|
||||
#define VERTEXARRAY_H
|
||||
|
||||
#include "declarations.h"
|
||||
#include <framework/util/databuffer.h>
|
||||
|
||||
class VertexArray
|
||||
{
|
||||
public:
|
||||
inline void addVertex(GLfloat x, GLfloat y) { m_buffer << x << y; }
|
||||
inline void addRect(const Rect& rect) {
|
||||
GLfloat top = rect.top();
|
||||
GLfloat right = rect.right()+1;
|
||||
GLfloat bottom = rect.bottom()+1;
|
||||
GLfloat left = rect.left();
|
||||
|
||||
addVertex(left, top);
|
||||
addVertex(right, top);
|
||||
addVertex(left, bottom);
|
||||
addVertex(left, bottom);
|
||||
addVertex(right, top);
|
||||
addVertex(right, bottom);
|
||||
}
|
||||
|
||||
inline void addQuad(const Rect& rect) {
|
||||
GLfloat top = rect.top();
|
||||
GLfloat right = rect.right()+1;
|
||||
GLfloat bottom = rect.bottom()+1;
|
||||
GLfloat left = rect.left();
|
||||
|
||||
addVertex(left, top);
|
||||
addVertex(right, top);
|
||||
addVertex(left, bottom);
|
||||
addVertex(right, bottom);
|
||||
}
|
||||
|
||||
void clear() { m_buffer.reset(); }
|
||||
GLfloat *vertexArray() const { return m_buffer.data(); }
|
||||
int vertexCount() const { return m_buffer.size() / 2; }
|
||||
|
||||
private:
|
||||
DataBuffer<GLfloat> m_buffer;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef DATABUFFER_H
|
||||
#define DATABUFFER_H
|
||||
|
||||
template<class T>
|
||||
class DataBuffer
|
||||
{
|
||||
public:
|
||||
DataBuffer(int res = 64) {
|
||||
m_capacity = res;
|
||||
m_buffer = new T[m_capacity];
|
||||
m_size = 0;
|
||||
}
|
||||
~DataBuffer() { delete[] m_buffer; }
|
||||
|
||||
inline void reset() { m_size = 0; }
|
||||
inline bool isEmpty() const { return m_size == 0; }
|
||||
|
||||
inline int size() const { return m_size; }
|
||||
inline T *data() const { return m_buffer; }
|
||||
|
||||
inline const T& at(int i) const { return m_buffer[i]; }
|
||||
inline const T& last() const { return m_buffer[m_size-1]; }
|
||||
inline const T& first() const { return m_buffer[0]; }
|
||||
inline const T& operator[](int i) const { return m_buffer[i]; }
|
||||
inline T& operator[](int i) { return m_buffer[i]; }
|
||||
|
||||
inline void add(const T &t) {
|
||||
if(m_size >= m_capacity) {
|
||||
m_capacity *= 2;
|
||||
T *buffer = new T[m_capacity];
|
||||
for(int i=0;i<m_size;++i)
|
||||
buffer[i] = m_buffer[i];
|
||||
delete[] m_buffer;
|
||||
m_buffer = buffer;
|
||||
}
|
||||
m_buffer[m_size++] = t;
|
||||
}
|
||||
|
||||
inline DataBuffer &operator<<(const T &t) { add(t); return *this; }
|
||||
|
||||
private:
|
||||
int m_size;
|
||||
int m_capacity;
|
||||
T *m_buffer;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in new issue