Does OpenGL allow you to save a portion of your model rather than repeatedly drawing the same thing over and over?

I am currently writing a program which is causing high cpu usage (24% by itself) and 100% gpu usage.

It seems to me that it is inefficient to run the program through a loop which does a whole lot of the same thing over and over. 99% of my current program, is things that never change. My current model has no moving parts yet, unless you count the occasional rotation applied by keystrokes, but even that doesn’t change the model, it only changes the way you see it. So what I have is a whole lot of things that never change and a camera angle that changes infrequently.

It seems to me I should have no gpu usage. The irony is that I learned OpenGl long ago, right about the time of its inception. I still haven’t learned the new core/shader stuff. I’m using GLFW which, I am often told doesn’t utilize the hardware. Then why is it at 100% usage? lol.

Off topic: So, what am I doing that is causing this high gpu/cpu usage?
I think a lot of it is from applying portions of one large texture to a lot of different triangles. I’m pretty sure that is where the cpu usage is coming from, because to do that, I have to do a lot of cpu math to select the correct portion of the texture. I suppose that might be causing the GPU usage too as I am constantly feeding calculations into tex coords and vertices. That also seems inefficient to me. I initially tried to set some anchor tex coords, figuring the texture would be properly wrapped across all of my triangles just from 4 corners. Nope. Every single vertex needs to be given its own tex coord. I feel like it should only need 4. Given a 2d texture, applied on a 3d surface it already has the range of x and y. The vertex of each corner tex coord could set those boundaries. I don’t think the CPU should have to do that. I could massively lower the CPU usage by saving the tex coord parameters along with my vertices. Memory isn’t currently an issue I’m using very little actually, but saving 5 points of data for each vertex seems inefficient too.

If you want your application to only render new frames when there was input, one thing you can do is replace glfwPollEvents with glfwWaitEvents. The latter will block until your application receives events from the OS, so your main loop (I assume that is where your do your rendering) does not constantly run.
The downside of course is that if there are no events from the OS your application does not render. If you wanted something to move while a button is pressed (instead of only when the button changes from released to pressed) this does not work, because you typically only get events when the button state changes - or possibly the OS sends you repeat events, but those are usually at a lower frequency than what is needed for smooth animation.

TY. That is an excellent workaround for now, except that drawing is triggered by mouse movement. I’m occasionally using the mouse to edit the display, so maybe what I really need is to not have a while loop, but instead have a function which is called whenever there is a keyboard event or specific mouse events. But then I still need a while loop, to call poll/wait events, rendering just won’t be in it.

Show what your program is with a picture. How big is your 3D model / world? Are you using glVertex3f() calls? Yes you need to update to modern openGL.

Everything else you posted is impossible to understand. A vertex on a cube cannot be shared. It needs to be duplicated because each face it belongs to gives it a different texture coordinate. It’s called vertex splitting.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.