Can toggle between fullscreen and windowed :)

This commit is contained in:
Themaister 2010-05-26 21:41:57 +02:00
parent eed8e2bed2
commit 7c678fc334
2 changed files with 24 additions and 6 deletions

View File

@ -16,6 +16,11 @@ struct snes_keybind
int joykey;
};
#define SAVE_STATE_KEY GLFW_KEY_F2
#define LOAD_STATE_KEY GLFW_KEY_F4
#define TOGGLE_FULLSCREEN 'F'
static const bool force_aspect = true; // On resize and fullscreen, rendering area will stay 8:7
// Windowed
@ -23,7 +28,8 @@ static const float xscale = 5.0; // Real x res = 256 * xscale
static const float yscale = 5.0; // Real y res = 224 * yscale
// Fullscreen
static const bool fullscreen = false;
static bool fullscreen = false; // To start in Fullscreen on not
static const unsigned fullscreen_x = 1920;
static const unsigned fullscreen_y = 1200;

22
ssnes.c
View File

@ -117,6 +117,12 @@ static void init_audio(void)
}
}
static void uninit_audio(void)
{
rsd_stop(rd);
rsd_free(rd);
}
static void video_refresh_GL(const uint16_t* data, unsigned width, unsigned height)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -308,10 +314,18 @@ int main(int argc, char *argv[])
if ( quitting )
break;
if ( glfwGetKey( GLFW_KEY_F2 ))
if ( glfwGetKey( SAVE_STATE_KEY ))
snes_serialize(serial_data, serial_size);
else if ( glfwGetKey(GLFW_KEY_F4) )
else if ( glfwGetKey( LOAD_STATE_KEY ) )
snes_unserialize(serial_data, serial_size);
else if ( glfwGetKey( TOGGLE_FULLSCREEN ) )
{
fullscreen = !fullscreen;
uninit_gl();
init_gl();
uninit_audio();
init_audio();
}
snes_run();
}
@ -328,9 +342,7 @@ int main(int argc, char *argv[])
snes_term();
uninit_gl();
rsd_stop(rd);
rsd_free(rd);
uninit_audio();
return 0;
}