Modifying face brightness/darkness within begin/end

Started by Iceweasel44, March 06, 2013, 23:34:32

Previous topic - Next topic

Iceweasel44

I am rendering a scene via calls to GL11.glBegin(GL11.GL_QUADS) that consists of a large amount of textured tiles(quads). Each tile can have a varied darkness to it that needs to be able to change at any time. Currently, I can achieve this by setting the appropriate light value/location (using a call to glLight and enabling), but this means I need to begin/end for each tile. I would like to be able to render as many tiles as possible with a single begin/end, but I can't modify lighting without ending and re-beginning. Are there any decent alternatives to that where I might be able to change the darkness of a textured face without breaking the begin/end chunks?

CodeBunny

Pretty sure you can't modify lighting during a glBegin/End.

Maybe you could do something with shaders? Simple example: if you're not using the glNormal vector for anything, send relevant data to your shader with that. You can do it per-tile in your draw call.

quew8

Why do you want to reduce the number of glBegins? I don't think there's a very big performance loss for using too many of them. Certainly if that's the concern then vbos would be the path to choose.
Also, now I think of it (it has been a long time since I used gl lighting) glMaterial is per vertex so you can use that to change the effect of lighting within a glBegin / glEnd pair. Surely this method would be more appropriate anyway? Sorry if this was all wrong.

Iceweasel44

I tried using another rendering method (not sure if vbos; made some geometry and texture vertices and then rendered it all in one call), but I ran into a couple of issues, all of which I have forgotten; this project has apparently been running on for too long :/
I've optimised my drawing a little bit since initially posting this, so its no longer per tile, but still not one big chunk. Its suitable for now, though. I'm still learning OpenGL, so I'll probably try either of these methods at some point. Thanks!