Jump to content
  • Advertisement
Sign in to follow this  
Milkies

OpenGL OpenGL for emulator programming

This topic is 3630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys, I have wrote a gameboy emulator that seems to be working great, however im having speed issues with the graphic emulation with opengl. I know next to nothing about OpenGL because i've never needed it except this one small function in my emulators. Hopefully if I describe how im doing things you might be able to suggest a speedier way of doing things. Here is my current code:
unsigned char screenData[160][144][3];
void RenderGame()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRasterPos2i(-1, 1);
glPixelZoom(1, -1);
glDrawPixels(160, 144, GL_RGB, GL_UNSIGNED_BYTE, screenData);
SDL_GL_SwapBuffers( ) ;
glFlush();
}
The above code is supposed to be called 60 times a second. Thats all the opengl in my emulator. As I said it works fine, just not fast enough. It runs at 60FPS on my machine but its a pretty fast machine. On my slow Asus EEE it runs at about 20FPS whereas a playstation emulator runs at 50FPS. So if a playstation emulator runs at 50FPS surely my gameboy emulator can run at 60FPS. The way I calculate the contents of the screenData variable is the same way the original gameboy does. It colours each pixel at a time depending on what horizontal row is currently being drawn. Someone recommeded a dirty rectangle but I dont know how that would work. Also one other issue im having. The current resolution is 160x144 but i want the user to be able to make it bigger by pressing keyboard key '+' (which i can detect in opengl). How would I edit the above code so it changed the display to x2 of its current resolution? Thanks for any help

Share this post


Link to post
Share on other sites
Advertisement
Thanks for the reply.

I made the changes and it did improve it a bit. Anyone else have any ideas or a way to do the scaling i mentioned?

Thanks again

Share this post


Link to post
Share on other sites
Does Opengl net you anything in this case? Sdl comes with support for doing bit blits directly instead of going through opengl.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!