From 98d31ab5a5ee69e097ec1e47e38d4d940ed64331 Mon Sep 17 00:00:00 2001 From: Bryan Hoyle Date: Sun, 12 Aug 2012 16:32:28 -0400 Subject: [PATCH] Fixed brush for now, used inefficient algorithm until I can get pure opengl working --- .gitignore | 1 + src/game/Brush.h | 3 ++- src/graphics/OpenGLDrawMethods.inl | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c7c2fb23a..02658a0b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*nohup.out *.swp *.o *.exe diff --git a/src/game/Brush.h b/src/game/Brush.h index a7f88f694..068ecf5ec 100644 --- a/src/game/Brush.h +++ b/src/game/Brush.h @@ -4,7 +4,6 @@ * Created on: Jan 22, 2012 * Author: Simon */ - #ifndef BRUSH_H_ #define BRUSH_H_ @@ -33,7 +32,9 @@ protected: for(int y = 0; y < size.Y; y++) { if(bitmap[y*size.X+x] && (!y || !x || x == size.X-1 || y == size.Y-1 || !bitmap[y*size.X+(x+1)] || !bitmap[y*size.X+(x-1)] || !bitmap[(y-1)*size.X+x] || !bitmap[(y+1)*size.X+x])) + { outline[y*size.X+x] = 255; + } else outline[y*size.X+x] = 0; } diff --git a/src/graphics/OpenGLDrawMethods.inl b/src/graphics/OpenGLDrawMethods.inl index 37f3002c7..fb443e9dc 100644 --- a/src/graphics/OpenGLDrawMethods.inl +++ b/src/graphics/OpenGLDrawMethods.inl @@ -214,6 +214,7 @@ void PIXELMETHODS_CLASS::xor_rect(int x, int y, int width, int height) void PIXELMETHODS_CLASS::xor_bitmap(unsigned char * bitmap, int x, int y, int w, int h) { + /* Rewriting until better method can be found //glEnable(GL_COLOR_LOGIC_OP); //glLogicOp(GL_XOR); glEnable(GL_TEXTURE_2D); @@ -222,8 +223,7 @@ void PIXELMETHODS_CLASS::xor_bitmap(unsigned char * bitmap, int x, int y, int w, glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap); - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap); glBegin(GL_QUADS); glTexCoord2d(0, 0); @@ -239,6 +239,18 @@ void PIXELMETHODS_CLASS::xor_bitmap(unsigned char * bitmap, int x, int y, int w, glBindTexture(GL_TEXTURE_2D, 0); glDisable(GL_TEXTURE_2D); //glDisable(GL_COLOR_LOGIC_OP); + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + */ + glColor4f(1.0f,1.0f,1.0f,1.0f); + for(int i =0; i < w*h; i++) + { + if(bitmap[i]==255) + { + glBegin(GL_POINTS); + glVertex2f(x+i%w,y+i/w); + glEnd(); + } + } } void PIXELMETHODS_CLASS::draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a)