PDA

View Full Version : Why shouldn't I use Immediate Mode for 2D?



GameBoyAdvance
02-28-2017, 05:51 PM
1. Immediate mode is fast enough for 2D ? (http://pastebin.com/pgSFJsYv this renders smoothly)
2. Are there any specific limitations when using Immediate Mode?
3. Shaders - they work just fine with immediate mode (is this always true?)
4. Tried vbo streaming batches (http://pastebin.com/fRMv6xLL and for some reason the same example runs waaay slower than the immediate mode example) - am I doing something wrong?

Using glew/SDL2
Target: OpenGL 2.1-4.5

Dark Photon
02-28-2017, 06:18 PM
1. Immediate mode is fast enough for 2D ? (http://pastebin.com/pgSFJsYv this renders smoothly)

If it's fast enough for you, use it. Just keep in mind it uses quite a bit more CPU for submitting draw commands to OpenGL than necessary. This ancient mode makes very inefficient use of the CPU and GPU. For a test app only you're going to use, I wouldn't worry about it though.


2. Are there any specific limitations when using Immediate Mode?

Yes. Excessive CPU consumption. There are others, but whether you care about them depends on your use case.


3. Shaders - they work just fine with immediate mode (is this always true?)

Yes, I believe so.



4. Tried vbo streaming batches (http://pastebin.com/fRMv6xLL and for some reason the same example runs waaay slower than the immediate mode example) - am I doing something wrong?

Yeah. That's not really an efficient vbo streaming method. I'd recommend reading this wiki page for more efficient options:

* Buffer Object Streaming (https://www.khronos.org/opengl/wiki/Buffer_Object_Streaming)

A mid-ground stepping stone between immediate mode and efficiently-employed streaming buffer objects is to use 2) vertex arrays stored in client (app) memory (aka client arrays). This also sets you up pretty well for moving to streaming buffer objects when you're ready.

GameBoyAdvance
02-28-2017, 07:13 PM
If it's fast enough for you, use it. Just keep in mind it uses quite a bit more CPU for submitting draw commands to OpenGL than necessary. This ancient mode makes very inefficient use of the CPU and GPU. For a test app only you're going to use, I wouldn't worry about it though.



Yes. Excessive CPU consumption. There are others, but whether you care about them depends on your use case.



Yes, I believe so.




Yeah. That's not really an efficient vbostreaming method. I'd recommend reading this wiki page for more efficient options:

* Buffer Object Streaming (https://www.khronos.org/opengl/wiki/Buffer_Object_Streaming)

A mid-ground stepping stone between immediate mode and efficiently-employed streaming buffer objects is to use 2) vertex arrays stored in client (app) memory (aka client arrays). This also sets you up pretty well for moving to streaming buffer objects when you're ready.

Thank you so much for your reply! It clarified a lot about 2D rendering to me :D .