void retro_run(void) { bool updated = false; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) check_variables(); update_input(); JaguarExecuteNew(); static int lastw=STARTWIDTH; if(lastw!=TOMGetVideoModeWidth()){ retro_get_system_av_info(&g_av_info); printf("width change:%d-" ,lastw); lastw=TOMGetVideoModeWidth(); printf(">%d\n" ,lastw); game_width = TOMGetVideoModeWidth(); game_height = TOMGetVideoModeHeight(); tomWidth = game_width; tomHeight = game_height; printf("new res:%dx%d %f\n",game_width,game_height,(float)game_width/game_height); bool ret; ret = environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &g_av_info.geometry); } SDLSoundCallback(NULL,sampleBuffer, vjs.hardwareTypeNTSC==1?BUFNTSC:BUFPAL); video_cb(videoBuffer, game_width, game_height, MAXWIDTH << 2); audio_batch_cb((int16_t *)sampleBuffer, vjs.hardwareTypeNTSC==1?BUFNTSC/2:BUFPAL/2); }
void GLWidget::paintGL() { // If we're in fullscreen mode, we take the value of the screen width as // set by MainWin, since it may be wider than what our aspect ratio allows. // In that case, we adjust the viewport over so that it's centered on the // screen. Otherwise, we simply take the width from our width() funtion // which will always be correct in windowed mode. if (!fullscreen) outputWidth = width(); // Bit 0 in VP is interlace flag. 0 = interlace, 1 = non-interlaced double multiplier = (TOMGetVP() & 0x0001 ? 1.0 : 2.0); unsigned outputHeight = height(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, outputWidth, 0, outputHeight, -1.0, 1.0); glViewport(0 + offset, 0, outputWidth, outputHeight); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (vjs.glFilter ? GL_LINEAR : GL_NEAREST)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (vjs.glFilter ? GL_LINEAR : GL_NEAREST)); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TOMGetVideoModeWidth(), rasterHeight * multiplier, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, buffer); double w = (double)TOMGetVideoModeWidth() / (double)textureWidth; double h = ((double)rasterHeight * multiplier) / (double)textureHeight; unsigned u = outputWidth; unsigned v = outputHeight; glBegin(GL_TRIANGLE_STRIP); glTexCoord2f(0, 0); glVertex3i(0, v, 0); glTexCoord2f(w, 0); glVertex3i(u, v, 0); glTexCoord2f(0, h); glVertex3i(0, 0, 0); glTexCoord2f(w, h); glVertex3i(u, 0, 0); glEnd(); }