Make EnableTex/DisableTex public
BlitzMax Forums/BlitzMax Module Tweaks/Make EnableTex/DisableTex public
| ||
Hi All the Max2D functions set the current texture through a private helper function called EnableTex, which is a wrapper for glBindTexture. Related code is here Function BindTex( name ) If name=state_boundtex Return glBindTexture GL_TEXTURE_2D,name state_boundtex=name End Function Function EnableTex( name ) BindTex name If state_texenabled Return glEnable GL_TEXTURE_2D state_texenabled=True End Function Function DisableTex() If Not state_texenabled Return glDisable GL_TEXTURE_2D state_texenabled=False End Function As you can see, it essentially does nothing if the same texture is activate more than once in a row. The trouble is that we can't get to the state_boundtex variable if we ever want to call glBindTexture ourselves. This demonstrates the problem: Graphics 640,480,0 img1:TImage = LoadImage("ball.png") img2:TPixmap = LoadPixmap("arrow.png") texture_name:Int = bglTexFromPixmap(img2) Cls DrawImage img1,100,100 glBindTexture GL_TEXTURE_2D, texture_name DrawImage img1,300,100 Flip WaitKey You should see "ball.png" displayed twice, but instead you see "ball.png" and "arrow.png" displayed side-by-side. If we could replace the glBindTexture line with a call to EnableTex this problem would go away and it would be easier to make "Max2D-compatible" modules. Cheers, |
| ||
I agree. |
| ||
Hmm interesting. And yah, another confusing thing about OpenGL is calling each texture a `name` - it's a number, nothing alphabetical at all, which is not at all intuitive. |