irrlicht icon indicating copy to clipboard operation
irrlicht copied to clipboard

Change OpenGL 3 Renderer to Core Profile

Open calebabutler opened this issue 2 years ago • 8 comments

This is a much smaller pull request compared to my previous one that only switches to the 3.3 core profile without any of the other major changes. I also cleaned up the code a little bit and made the reasons why I was commenting certain things out more obvious.

calebabutler avatar Sep 13 '23 15:09 calebabutler

Thanks for the PR. Maybe instead of using a global, split beginDraw into pointer-accepting and offset-accepting versions, so that the former prepares the buffer and calls the latter? Would that integrate well with the existing call sites?

numberZero avatar Sep 17 '23 18:09 numberZero

Thank you, it required a little bit of reworking the drawHardwareBuffer and drawVectorPrimitiveList functions, but I replaced the global with two functions as I agree that that is a much better way of doing it.

calebabutler avatar Sep 17 '23 20:09 calebabutler

it required a little bit of reworking the drawHardwareBuffer

I guess EHM_NEVER is going to cause grief anyway. And it’s the default IIUC...

Some time ago, I’ve seen code that simply replaces EHM_NEVER with something else, in all buffers, everywhere, just to make it work with WebGL (which can only render from buffers, just like GL Core). Not the cleanest way but it suggests that treating EHM_NEVER like something else in the whole driver may very well work.

Also, how do you handle index buffers?

numberZero avatar Sep 20 '23 18:09 numberZero

Thank you for the code correction, and you were absolutely right about changing that type. So, right now my video driver handles index buffers in not such a good way; it assumes GL_ELEMENT_ARRAY_BUFFER is bound before calling drawVertexPrimitiveList when you call the function in one of the modes that ends up calling glDrawElements. I'm sure this can be done much better. I realized I was not handling the EHM_NEVER case right ever, so I changed the code slightly, for vertex buffers it can (kind of) handle it by using the global VBO, and for index buffers it just ignores it. If this is going in the wrong direction let me know.

calebabutler avatar Sep 21 '23 23:09 calebabutler

Ignoring EHM_NEVER works fine for WebGL: https://github.com/minetest/irrlicht/blob/cfb73d07d7248ef3dd3876f139a59d568244968e/source/Irrlicht/CWebGL1Driver.cpp#L77-L95 So should be fine on GL3 as well, as long as is done properly and systematically and doesn’t cause any leaks (Irrlicht way of caching meshes is prone of that to my knowledge).

numberZero avatar Sep 28 '23 17:09 numberZero

Assuming this is superseded due to #250

sfan5 avatar Oct 27 '23 15:10 sfan5

@sfan5 no it isn’t. Only #232 is, with #250 and this one together.

numberZero avatar Oct 28 '23 20:10 numberZero

@calebabutler Any news on this?

And on EHM_NEVER on index buffers: I now think just ignoring one is wrong, it’s better to handle it the same way as vertices, moving to a buffer just before rendering. To reduce potential surprises from the “hw buffer link” and whatever else. I’d not expose any mixed RAM/VBO calls though, keeping all that stuff as an internal detail.

numberZero avatar Nov 06 '23 15:11 numberZero