Fixed brush for now, used inefficient algorithm until I can get pure opengl working

This commit is contained in:
Bryan Hoyle 2012-08-12 16:32:28 -04:00
parent f9a59d22db
commit 98d31ab5a5
3 changed files with 17 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*nohup.out
*.swp
*.o
*.exe

View File

@ -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;
}

View File

@ -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)