Fixed brush for now, used inefficient algorithm until I can get pure opengl working
This commit is contained in:
parent
f9a59d22db
commit
98d31ab5a5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
*nohup.out
|
||||||
*.swp
|
*.swp
|
||||||
*.o
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
* Created on: Jan 22, 2012
|
* Created on: Jan 22, 2012
|
||||||
* Author: Simon
|
* Author: Simon
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BRUSH_H_
|
#ifndef BRUSH_H_
|
||||||
#define BRUSH_H_
|
#define BRUSH_H_
|
||||||
|
|
||||||
@ -33,7 +32,9 @@ protected:
|
|||||||
for(int y = 0; y < size.Y; y++)
|
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]))
|
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;
|
outline[y*size.X+x] = 255;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
outline[y*size.X+x] = 0;
|
outline[y*size.X+x] = 0;
|
||||||
}
|
}
|
||||||
|
@ -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)
|
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);
|
//glEnable(GL_COLOR_LOGIC_OP);
|
||||||
//glLogicOp(GL_XOR);
|
//glLogicOp(GL_XOR);
|
||||||
glEnable(GL_TEXTURE_2D);
|
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);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, bitmap);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2d(0, 0);
|
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);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
//glDisable(GL_COLOR_LOGIC_OP);
|
//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)
|
void PIXELMETHODS_CLASS::draw_line(int x, int y, int x2, int y2, int r, int g, int b, int a)
|
||||||
|
Loading…
Reference in New Issue
Block a user