summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Hoyle <starfoxprime@gmail.com>2012-08-12 20:32:28 (GMT)
committer Bryan Hoyle <starfoxprime@gmail.com>2012-08-12 20:32:28 (GMT)
commit98d31ab5a5ee69e097ec1e47e38d4d940ed64331 (patch)
tree522b836b8b2ca7858b7d04eb3fd44fea589e5102
parentf9a59d22dbd2e28ed39c92032eaf2ad397521416 (diff)
downloadpowder-98d31ab5a5ee69e097ec1e47e38d4d940ed64331.zip
powder-98d31ab5a5ee69e097ec1e47e38d4d940ed64331.tar.gz
Fixed brush for now, used inefficient algorithm until I can get pure opengl working
-rw-r--r--.gitignore1
-rw-r--r--src/game/Brush.h3
-rw-r--r--src/graphics/OpenGLDrawMethods.inl16
3 files changed, 17 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index c7c2fb2..02658a0 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 a7f88f6..068ecf5 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 37f3002..fb443e9 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)