So I have been working in OpenGL for a few days and have a working animation and masking system working. But when I look at the program in the presses manager it says that its taking up about %50 CPU space!
Is this normal for OpenGL, or could it be my animation system. All I do for my animation system is make an object with all the frames Gluint textures. And it swaps the current texture when the timer goes pass the amount of time per frame.
Any one know why my program is taking up so much memory, I didn’t want to just past my code up here and say “what’s wrong with this†but if some one requests my code I will show it.
Resource managing in OpenGL
Moderator: Coders of Rage
- cloudncali
- Chaos Rift Newbie
- Posts: 13
- Joined: Sun Jan 18, 2009 8:36 pm
- Current Project: Random stuff
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Contact:
Resource managing in OpenGL
Come visit my youtube channel:
http://www.youtube.com/cloudncali
http://www.youtube.com/cloudncali
- LeonBlade
- Chaos Rift Demigod
- Posts: 1314
- Joined: Thu Jan 22, 2009 12:22 am
- Current Project: Trying to make my first engine in C++ using OGL
- Favorite Gaming Platforms: PS3
- Programming Language of Choice: C++
- Location: Blossvale, NY
Re: Resource managing in OpenGL
It shouldn't be unless your computer fails...
Post your code
Post your code
There's no place like ~/
- cloudncali
- Chaos Rift Newbie
- Posts: 13
- Joined: Sun Jan 18, 2009 8:36 pm
- Current Project: Random stuff
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Contact:
Re: Resource managing in OpenGL
Source.rar
That is the entire source code for the program, so far i only have one animated image and one non animated image that just rotates. so it doesn't seem like something that would be very resource needy. so its probably something in my code that's not very efficient.
just a quick overview:
App.h and App.cpp is the main program code, Main is just there for the Main Function.
GameObject.h has all the different classes for game objects(the three are Graphic object, Animated Graphic object, and Animation)
Animation object is just for animation
Animated Graphic Object has an Animated object in it and has other object properties.
Edit: An update and more info, i manage to lower that %50 to about %20 buy adding SDL_Delay(50) after the output funtion but i feel like that is a temporary fix
oh i forgot to mention that this is SDL+OpenGL not pure OpenGL
That is the entire source code for the program, so far i only have one animated image and one non animated image that just rotates. so it doesn't seem like something that would be very resource needy. so its probably something in my code that's not very efficient.
just a quick overview:
App.h and App.cpp is the main program code, Main is just there for the Main Function.
GameObject.h has all the different classes for game objects(the three are Graphic object, Animated Graphic object, and Animation)
Animation object is just for animation
Animated Graphic Object has an Animated object in it and has other object properties.
Edit: An update and more info, i manage to lower that %50 to about %20 buy adding SDL_Delay(50) after the output funtion but i feel like that is a temporary fix
oh i forgot to mention that this is SDL+OpenGL not pure OpenGL
Come visit my youtube channel:
http://www.youtube.com/cloudncali
http://www.youtube.com/cloudncali
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Resource managing in OpenGL
I have a feeling that there's nothing wrong with your code. OpenGL just is resource heavy (in the CPU department).
Re: Resource managing in OpenGL
First of, there is no such thing as CPU space.
CPU usage is measured over time and 50% CPU usage means that 50% of the time the CPU spends executing anything is spent on your program.
So I don't think this has anything to do with OpenGL or something that's wrong with your program.
You're probably just not limiting the framerate of your program and that's why it's using all the cpu time that's available.
I suspect you're machine is equipped with a dual core processor, which is why only 50% (1 core) of the CPU time is used.
Edit:
If your main game loop is like this:
It's always going to use as much CPU time as is available, regardless of what you do in that loop.
(Except for actively telling the Operating System to stop executing your program for a while, which is what SDL_Delay does.)
So it's not really a big deal if 50% of CPU time is used.
CPU usage is measured over time and 50% CPU usage means that 50% of the time the CPU spends executing anything is spent on your program.
So I don't think this has anything to do with OpenGL or something that's wrong with your program.
You're probably just not limiting the framerate of your program and that's why it's using all the cpu time that's available.
I suspect you're machine is equipped with a dual core processor, which is why only 50% (1 core) of the CPU time is used.
Edit:
If your main game loop is like this:
Code: Select all
while(gameIsRunning)
{
// do opengl stuff
}
(Except for actively telling the Operating System to stop executing your program for a while, which is what SDL_Delay does.)
So it's not really a big deal if 50% of CPU time is used.
177
- cloudncali
- Chaos Rift Newbie
- Posts: 13
- Joined: Sun Jan 18, 2009 8:36 pm
- Current Project: Random stuff
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Contact:
Re: Resource managing in OpenGL
ok thanks for the help.but now Ihave another problem related to OpenGL, I have a for some reason with my working set up I have 1 animated graphic and 2 static graphics(one is rotating with OpenGLs rotate function). But this causes the game to become abnormal slow, like the rotating graphic lags like non other. I will look into this more later, but if any one knows what could be causing the game to lag please tell me what i can do different.
Come visit my youtube channel:
http://www.youtube.com/cloudncali
http://www.youtube.com/cloudncali