diff options
Diffstat (limited to 'src/libjin/Graphics/je_drawable.cpp')
-rw-r--r-- | src/libjin/Graphics/je_drawable.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/libjin/Graphics/je_drawable.cpp b/src/libjin/Graphics/je_drawable.cpp index 00ff739..af9e4d8 100644 --- a/src/libjin/Graphics/je_drawable.cpp +++ b/src/libjin/Graphics/je_drawable.cpp @@ -14,42 +14,42 @@ namespace JinEngine { Drawable::Drawable(int w, int h) - : texture(0) - , size(w, h) - , anchor(0, 0) + : mTexture(0) + , mSize(w, h) + , mOrigin(0, 0) { - vertex_coords[0] = 0; vertex_coords[1] = 0; - vertex_coords[2] = 0; vertex_coords[3] = h; - vertex_coords[4] = w; vertex_coords[5] = h; - vertex_coords[6] = w; vertex_coords[7] = 0; - - texture_coords[0] = 0; texture_coords[1] = 0; - texture_coords[2] = 0; texture_coords[3] = 1; - texture_coords[4] = 1; texture_coords[5] = 1; - texture_coords[6] = 1; texture_coords[7] = 0; + mVertexCoords[0] = 0; mVertexCoords[1] = 0; + mVertexCoords[2] = 0; mVertexCoords[3] = h; + mVertexCoords[4] = w; mVertexCoords[5] = h; + mVertexCoords[6] = w; mVertexCoords[7] = 0; + + mTextureCoords[0] = 0; mTextureCoords[1] = 0; + mTextureCoords[2] = 0; mTextureCoords[3] = 1; + mTextureCoords[4] = 1; mTextureCoords[5] = 1; + mTextureCoords[6] = 1; mTextureCoords[7] = 0; } Drawable::Drawable(const Bitmap* bitmap) - : texture(0) - , anchor(0, 0) + : mTexture(0) + , mOrigin(0, 0) { - unsigned int w = size.w = bitmap->getWidth(); - unsigned int h = size.h = bitmap->getHeight(); + uint32 w = mSize.w = bitmap->getWidth(); + uint32 h = mSize.h = bitmap->getHeight(); - vertex_coords[0] = 0; vertex_coords[1] = 0; - vertex_coords[2] = 0; vertex_coords[3] = h; - vertex_coords[4] = w; vertex_coords[5] = h; - vertex_coords[6] = w; vertex_coords[7] = 0; + mVertexCoords[0] = 0; mVertexCoords[1] = 0; + mVertexCoords[2] = 0; mVertexCoords[3] = h; + mVertexCoords[4] = w; mVertexCoords[5] = h; + mVertexCoords[6] = w; mVertexCoords[7] = 0; - texture_coords[0] = 0; texture_coords[1] = 0; - texture_coords[2] = 0; texture_coords[3] = 1; - texture_coords[4] = 1; texture_coords[5] = 1; - texture_coords[6] = 1; texture_coords[7] = 0; + mTextureCoords[0] = 0; mTextureCoords[1] = 0; + mTextureCoords[2] = 0; mTextureCoords[3] = 1; + mTextureCoords[4] = 1; mTextureCoords[5] = 1; + mTextureCoords[6] = 1; mTextureCoords[7] = 0; const Color* pixels = bitmap->getPixels(); - texture = gl.genTexture(); - gl.bindTexture(texture); + mTexture = gl.genTexture(); + gl.bindTexture(mTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl.texImage(GL_RGBA8, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); @@ -58,26 +58,26 @@ namespace JinEngine Drawable::~Drawable() { - glDeleteTextures(1, &texture); + glDeleteTextures(1, &mTexture); } - void Drawable::setAnchor(int x, int y) + void Drawable::setOrigin(int x, int y) { - anchor.x = x; - anchor.y = y; + mOrigin.x = x; + mOrigin.y = y; } void Drawable::draw(int x, int y, float sx, float sy, float r) { - gl.ModelMatrix.setTransformation(x, y, r, sx, sy, anchor.x, anchor.y); + gl.ModelMatrix.setTransformation(x, y, r, sx, sy, mOrigin.x, mOrigin.y); Shader* shader = Shader::getCurrentShader(); shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); - shader->bindVertexPointer(2, GL_FLOAT, 0, vertex_coords); - shader->bindUVPointer(2, GL_FLOAT, 0, texture_coords); + shader->bindVertexPointer(2, GL_FLOAT, 0, mVertexCoords); + shader->bindUVPointer(2, GL_FLOAT, 0, mTextureCoords); - gl.bindTexture(texture); + gl.bindTexture(mTexture); gl.drawArrays(GL_QUADS, 0, 4); gl.bindTexture(0); } @@ -90,10 +90,10 @@ namespace JinEngine slice.w, slice.h, slice.w, 0 }; - float slx = slice.x / size.w; - float sly = slice.y / size.h; - float slw = slice.w / size.w; - float slh = slice.h / size.h; + float slx = slice.x / mSize.w; + float sly = slice.y / mSize.h; + float slw = slice.w / mSize.w; + float slh = slice.h / mSize.h; float texCoords[8] = { slx, sly, slx, sly + slh, @@ -109,7 +109,7 @@ namespace JinEngine shader->bindVertexPointer(2, GL_FLOAT, 0, vertCoords); shader->bindUVPointer(2, GL_FLOAT, 0, texCoords); - gl.bindTexture(texture); + gl.bindTexture(mTexture); gl.drawArrays(GL_QUADS, 0, 4); gl.bindTexture(0); } |