use OGL 1.1 color logic ops in addition to GL_EXT_blend_logic_op
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
GLenum doubleBuffer;
|
GLenum doubleBuffer;
|
||||||
static int dithering = 0;
|
static int dithering = 0;
|
||||||
|
int use11ops = 0;
|
||||||
|
int supportlogops = 0;
|
||||||
static int doPrint = 1;
|
static int doPrint = 1;
|
||||||
static int deltaY;
|
static int deltaY;
|
||||||
GLint windW, windH;
|
GLint windW, windH;
|
||||||
@@ -62,6 +64,13 @@ static void Key(unsigned char key, int x, int y)
|
|||||||
case 'd':
|
case 'd':
|
||||||
dithering = !dithering;
|
dithering = !dithering;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
if (supportlogops == 3)
|
||||||
|
use11ops = (!use11ops);
|
||||||
|
if (use11ops)
|
||||||
|
printf("Using GL 1.1 color logic ops.\n");
|
||||||
|
else printf("Using GL_EXT_blend_logic_op.\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -100,6 +109,8 @@ static void Draw(void)
|
|||||||
|
|
||||||
(dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER);
|
(dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
if (supportlogops & 2)
|
||||||
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
|
|
||||||
glClearColor(0.5, 0.6, 0.1, 1.0);
|
glClearColor(0.5, 0.6, 0.1, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
@@ -175,48 +186,46 @@ static void Draw(void)
|
|||||||
|
|
||||||
glBlendFunc(GL_ONE, GL_ZERO);
|
glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
if (!use11ops)
|
||||||
|
glBlendEquationEXT(GL_LOGIC_OP);
|
||||||
|
else
|
||||||
|
glEnable(GL_COLOR_LOGIC_OP);
|
||||||
glLogicOp(GL_CLEAR);
|
glLogicOp(GL_CLEAR);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
|
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
|
||||||
glLogicOp(GL_SET);
|
glLogicOp(GL_SET);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
|
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
|
||||||
glLogicOp(GL_COPY);
|
glLogicOp(GL_COPY);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
|
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
|
||||||
glLogicOp(GL_NOOP);
|
glLogicOp(GL_NOOP);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
|
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
|
||||||
glLogicOp(GL_AND);
|
glLogicOp(GL_AND);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
|
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
|
||||||
glLogicOp(GL_INVERT);
|
glLogicOp(GL_INVERT);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
|
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
|
||||||
glLogicOp(GL_OR);
|
glLogicOp(GL_OR);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
|
|
||||||
i -= deltaY;
|
i -= deltaY;
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
|
||||||
glLogicOp(GL_XOR);
|
glLogicOp(GL_XOR);
|
||||||
glRectf(x1, i, x2, i+deltaY);
|
glRectf(x1, i, x2, i+deltaY);
|
||||||
glRectf(x1, i+10, x2, i+5);
|
glRectf(x1, i+10, x2, i+5);
|
||||||
|
|
||||||
if (doPrint) {
|
if (doPrint) {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
if (supportlogops & 2)
|
||||||
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
glColor3f(1.0, 1.0, 1.0);
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
PrintColorStrings();
|
PrintColorStrings();
|
||||||
}
|
}
|
||||||
@@ -254,6 +263,7 @@ int main(int argc, char **argv)
|
|||||||
char *extName1 = "GL_EXT_blend_logic_op";
|
char *extName1 = "GL_EXT_blend_logic_op";
|
||||||
char *extName2 = "GL_EXT_blend_minmax";
|
char *extName2 = "GL_EXT_blend_minmax";
|
||||||
char *extName3 = "GL_EXT_blend_subtract";
|
char *extName3 = "GL_EXT_blend_subtract";
|
||||||
|
char *version;
|
||||||
|
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
@@ -273,10 +283,21 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Make sure blend_logic_op extension is there. */
|
/* Make sure blend_logic_op extension is there. */
|
||||||
s = (char *) glGetString(GL_EXTENSIONS);
|
s = (char *) glGetString(GL_EXTENSIONS);
|
||||||
|
version = (char*) glGetString(GL_VERSION);
|
||||||
if (!s)
|
if (!s)
|
||||||
exit(1);
|
exit(1);
|
||||||
if (strstr(s,extName1) == 0) {
|
if (strstr(s,extName1)) {
|
||||||
printf("Blend_logic_op extension is not present.\n");
|
supportlogops = 1;
|
||||||
|
use11ops = 0;
|
||||||
|
printf("blend_logic_op extension available.\n");
|
||||||
|
}
|
||||||
|
if (strncmp(version,"1.1",3)>=0) {
|
||||||
|
supportlogops += 2;
|
||||||
|
use11ops = 1;
|
||||||
|
printf("1.1 color logic ops available.\n");
|
||||||
|
}
|
||||||
|
if (supportlogops == 0) {
|
||||||
|
printf("Blend_logic_op extension and GL 1.1 not present.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (strstr(s,extName2) == 0) {
|
if (strstr(s,extName2) == 0) {
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
GLenum doubleBuffer;
|
GLenum doubleBuffer;
|
||||||
int dithering = 0;
|
int dithering = 0;
|
||||||
|
int use11ops = 0;
|
||||||
|
int supportlogops = 0;
|
||||||
GLint windW, windH;
|
GLint windW, windH;
|
||||||
|
|
||||||
static void Init(void)
|
static void Init(void)
|
||||||
@@ -50,6 +52,13 @@ static void Key(unsigned char key, int x, int y)
|
|||||||
case 'd':
|
case 'd':
|
||||||
dithering = !dithering;
|
dithering = !dithering;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
if (supportlogops == 3)
|
||||||
|
use11ops = (!use11ops);
|
||||||
|
if (use11ops)
|
||||||
|
printf("Using GL 1.1 color logic ops.\n");
|
||||||
|
else printf("Using GL_EXT_blend_logic_op.\n");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,6 +71,8 @@ static void Draw(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
if (supportlogops & 2)
|
||||||
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
|
|
||||||
(dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER);
|
(dithering) ? glEnable(GL_DITHER) : glDisable(GL_DITHER);
|
||||||
|
|
||||||
@@ -83,7 +94,10 @@ static void Draw(void)
|
|||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquationEXT(GL_LOGIC_OP);
|
if (!use11ops)
|
||||||
|
glBlendEquationEXT(GL_LOGIC_OP);
|
||||||
|
else
|
||||||
|
glEnable(GL_COLOR_LOGIC_OP);
|
||||||
glLogicOp(GL_XOR);
|
glLogicOp(GL_XOR);
|
||||||
|
|
||||||
/* Draw a set of rectangles across the window */
|
/* Draw a set of rectangles across the window */
|
||||||
@@ -142,6 +156,7 @@ int main(int argc, char **argv)
|
|||||||
GLenum type;
|
GLenum type;
|
||||||
char *s;
|
char *s;
|
||||||
char *extName = "GL_EXT_blend_logic_op";
|
char *extName = "GL_EXT_blend_logic_op";
|
||||||
|
char *version;
|
||||||
|
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
|
|
||||||
@@ -161,10 +176,21 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* Make sure blend_logic_op extension is there. */
|
/* Make sure blend_logic_op extension is there. */
|
||||||
s = (char *) glGetString(GL_EXTENSIONS);
|
s = (char *) glGetString(GL_EXTENSIONS);
|
||||||
|
version = (char*) glGetString(GL_VERSION);
|
||||||
if (!s)
|
if (!s)
|
||||||
exit(1);
|
exit(1);
|
||||||
if (strstr(s,extName) == 0) {
|
if (strstr(s,extName)) {
|
||||||
printf("Blend_logic_op extension is not present.\n");
|
supportlogops = 1;
|
||||||
|
use11ops = 0;
|
||||||
|
printf("blend_logic_op extension available.\n");
|
||||||
|
}
|
||||||
|
if (strncmp(version,"1.1",3)>=0) {
|
||||||
|
supportlogops += 2;
|
||||||
|
use11ops = 1;
|
||||||
|
printf("1.1 color logic ops available.\n");
|
||||||
|
}
|
||||||
|
if (supportlogops == 0) {
|
||||||
|
printf("Blend_logic_op extension and GL 1.1 not present.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user