diff options
Diffstat (limited to 'src/libjin/Graphics/je_graphic.cpp')
-rw-r--r-- | src/libjin/Graphics/je_graphic.cpp | 73 |
1 files changed, 4 insertions, 69 deletions
diff --git a/src/libjin/Graphics/je_graphic.cpp b/src/libjin/Graphics/je_graphic.cpp index cce0c74..86b6bf4 100644 --- a/src/libjin/Graphics/je_graphic.cpp +++ b/src/libjin/Graphics/je_graphic.cpp @@ -17,32 +17,14 @@ namespace JinEngine : mTexture(0) , mSize(w, h) { - 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; + mTexture = gl.genTexture(); } Graphic::Graphic(const Bitmap* bitmap) : mTexture(0) { - uint32 w = mSize.w = bitmap->getWidth(); - uint32 h = mSize.h = bitmap->getHeight(); - - 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; + mSize.w = bitmap->getWidth(); + mSize.h = bitmap->getHeight(); const Color* pixels = bitmap->getPixels(); @@ -50,7 +32,7 @@ namespace JinEngine 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); + gl.texImage(GL_RGBA8, mSize.w, mSize.h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); gl.bindTexture(0); } @@ -59,53 +41,6 @@ namespace JinEngine glDeleteTextures(1, &mTexture); } - void Graphic::render(int x, int y, float sx, float sy, float r, float ox, float oy) - { - gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ox, oy); - - Shader* shader = Shader::getCurrentShader(); - shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); - shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); - shader->bindVertexPointer(2, GL_FLOAT, 0, mVertexCoords); - shader->bindUVPointer(2, GL_FLOAT, 0, mTextureCoords); - - gl.bindTexture(mTexture); - gl.drawArrays(GL_QUADS, 0, 4); - gl.bindTexture(0); - } - - void Graphic::render(const Math::Quad& slice, int x, int y, float sx, float sy, float r, float ax, float ay) - { - float vertCoords[8] = { - 0, 0, - 0, slice.h, - slice.w, slice.h, - slice.w, 0 - }; - 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, - slx + slw, sly + slh, - slx + slw, sly - }; - - gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ax, ay); - - Shader* shader = Shader::getCurrentShader(); - shader->sendMatrix4(SHADER_MODEL_MATRIX, &gl.ModelMatrix); - shader->sendMatrix4(SHADER_PROJECTION_MATRIX, &gl.ProjectionMatrix); - shader->bindVertexPointer(2, GL_FLOAT, 0, vertCoords); - shader->bindUVPointer(2, GL_FLOAT, 0, texCoords); - - gl.bindTexture(mTexture); - gl.drawArrays(GL_QUADS, 0, 4); - gl.bindTexture(0); - } - //void Graphic::setFilter(GLint min, GLint max) //{ // glTexParameteri(GL_) |