Original Post
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