Mixing Max2D calls with OpenGL Calls

BlitzMax Forums/BlitzMax Beginners Area/Mixing Max2D calls with OpenGL Calls

juankprada(Posted 2013) [#1]
I'm trying something here. After rendering an image with Max2D's DrawImage I am executing the following openGL calls:

glBegin(GL_QUADS)
glVertex3f(200, 100, 0)
glVertex3f(400, 100, 0)
glVertex3f(400, 400, 0)
glVertex3f(200, 400, 0)
glEnd()


The result right now is that I get the image displaed on screen, but the quad is not rendered.

If i remove the call to DrawImage, I do get the quad renderd on screen.

So are Max2D and Opengl calls incompatible?


xlsior(Posted 2013) [#2]
Don't know if it makes a difference, but did you use GLShareContexts() before entering you graphicsmode?


juankprada(Posted 2013) [#3]
No, I am not using it. But event after adding it, I still get the same result.


jkrankie(Posted 2013) [#4]
you may need to unbind any textures and push a matrix in order to see anything. as i remember max2d doesn't leave the gl state very tidy.


ImaginaryHuman(Posted 2013) [#5]
To my knowledge this should be working. You can inject GL at any point. Max doesn't necessarily protect its GL state, it pushes and pops it but its the fact that you can do GL code anywhere that potentially interferes with what Max is expecting the state to be. But here you aren't changing state, only sending more geometry.

However, you said you did drawimage, which is textured, and here you are not providing any texture coordinates, or vertex colors.


juankprada(Posted 2013) [#6]
I did a glBindTexture(GL_TEXTURE_2D, 0) after the DrawImage and before my glBegin/glEnd code and now it works fine. I see both the image an the white square on the screen