mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-25 07:05:40 +00:00
Added OSD/Video.h to provide OSD-dependent video functionality. The static functions in here get called by Model3.cpp from within the render thread so that any OSD related rendering can also be run in parallel for a further speed increase.
Updated OSD/SDL/Main.cpp to provide the SDL implementations of the functions in OSD/Video.h.
This commit is contained in:
parent
84eb017744
commit
8a4ea64994
|
@ -1932,9 +1932,8 @@ void CModel3::RunFrame(void)
|
||||||
SyncGPUs();
|
SyncGPUs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render frame if ready to do so
|
// Render frame
|
||||||
if (gpusReady)
|
RenderFrame();
|
||||||
RenderFrame();
|
|
||||||
|
|
||||||
// Enter notify wait critical section
|
// Enter notify wait critical section
|
||||||
if (!notifyLock->Lock())
|
if (!notifyLock->Lock())
|
||||||
|
@ -2060,12 +2059,18 @@ void CModel3::RenderFrame(void)
|
||||||
{
|
{
|
||||||
UINT32 start = CThread::GetTicks();
|
UINT32 start = CThread::GetTicks();
|
||||||
|
|
||||||
// Render frame
|
// Call OSD video callbacks
|
||||||
TileGen.BeginFrame();
|
if (BeginFrameVideo() && gpusReady)
|
||||||
GPU.BeginFrame();
|
{
|
||||||
GPU.RenderFrame();
|
// Render frame
|
||||||
GPU.EndFrame();
|
TileGen.BeginFrame();
|
||||||
TileGen.EndFrame();
|
GPU.BeginFrame();
|
||||||
|
GPU.RenderFrame();
|
||||||
|
GPU.EndFrame();
|
||||||
|
TileGen.EndFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
EndFrameVideo();
|
||||||
|
|
||||||
renderTicks = CThread::GetTicks() - start;
|
renderTicks = CThread::GetTicks() - start;
|
||||||
}
|
}
|
||||||
|
|
|
@ -320,7 +320,6 @@ static void PrintGLInfo(bool createScreen, bool infoLog, bool printExtensions)
|
||||||
else printf("\n");
|
else printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
Configuration
|
Configuration
|
||||||
|
|
||||||
|
@ -718,6 +717,29 @@ static void UpdateCrosshairs(CInputs *Inputs, unsigned showCrosshairs)
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
Video Callbacks
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
static CInputs *videoInputs = NULL;
|
||||||
|
static unsigned videoShowCrosshairs = 0; // bit 1: player 1 crosshair, bit 0: player 2
|
||||||
|
|
||||||
|
bool BeginFrameVideo()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EndFrameVideo()
|
||||||
|
{
|
||||||
|
// Show crosshairs for light gun games
|
||||||
|
if (videoInputs)
|
||||||
|
UpdateCrosshairs(videoInputs, videoShowCrosshairs);
|
||||||
|
|
||||||
|
// Swap the buffers
|
||||||
|
SDL_GL_SwapBuffers();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
Main Program Loop
|
Main Program Loop
|
||||||
|
@ -737,7 +759,6 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine)
|
||||||
CRender3D *Render3D = new CRender3D();
|
CRender3D *Render3D = new CRender3D();
|
||||||
unsigned prevFPSTicks, currentFPSTicks, currentTicks, targetTicks, startTicks;
|
unsigned prevFPSTicks, currentFPSTicks, currentTicks, targetTicks, startTicks;
|
||||||
unsigned fpsFramesElapsed, framesElapsed;
|
unsigned fpsFramesElapsed, framesElapsed;
|
||||||
unsigned showCrosshairs = 0; // bit 1: player 1 crosshair, bit 0: player 2
|
|
||||||
bool gameHasLightguns = false;
|
bool gameHasLightguns = false;
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
|
@ -774,8 +795,14 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine)
|
||||||
// Hide mouse if fullscreen, enable crosshairs for gun games
|
// Hide mouse if fullscreen, enable crosshairs for gun games
|
||||||
Inputs->GetInputSystem()->SetMouseVisibility(!g_Config.fullScreen);
|
Inputs->GetInputSystem()->SetMouseVisibility(!g_Config.fullScreen);
|
||||||
gameHasLightguns = !!(Model3->GetGameInfo()->inputFlags & (GAME_INPUT_GUN1|GAME_INPUT_GUN2));
|
gameHasLightguns = !!(Model3->GetGameInfo()->inputFlags & (GAME_INPUT_GUN1|GAME_INPUT_GUN2));
|
||||||
if (g_Config.fullScreen && gameHasLightguns)
|
if (gameHasLightguns)
|
||||||
showCrosshairs = 1; // show player 1 cursor only by default (TODO: add an IsMapped() member to CInput to allow testing for both lightguns)
|
{
|
||||||
|
videoInputs = Inputs;
|
||||||
|
if (g_Config.fullScreen && gameHasLightguns)
|
||||||
|
videoShowCrosshairs = 1; // show player 1 cursor only by default (TODO: add an IsMapped() member to CInput to allow testing for both lightguns)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
videoInputs = NULL;
|
||||||
|
|
||||||
// Attach the inputs to the emulator
|
// Attach the inputs to the emulator
|
||||||
Model3->AttachInputs(Inputs);
|
Model3->AttachInputs(Inputs);
|
||||||
|
@ -812,12 +839,6 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine)
|
||||||
{
|
{
|
||||||
// If not, run one frame
|
// If not, run one frame
|
||||||
Model3->RunFrame();
|
Model3->RunFrame();
|
||||||
|
|
||||||
// Show crosshairs for light gun games
|
|
||||||
UpdateCrosshairs(Inputs, showCrosshairs);
|
|
||||||
|
|
||||||
// Swap the buffers
|
|
||||||
SDL_GL_SwapBuffers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll the inputs
|
// Poll the inputs
|
||||||
|
@ -1016,8 +1037,8 @@ int Supermodel(const char *zipFile, CInputs *Inputs, CINIFile *CmdLine)
|
||||||
}
|
}
|
||||||
else if (Inputs->uiSelectCrosshairs->Pressed() && gameHasLightguns)
|
else if (Inputs->uiSelectCrosshairs->Pressed() && gameHasLightguns)
|
||||||
{
|
{
|
||||||
showCrosshairs++;
|
videoShowCrosshairs++;
|
||||||
switch ((showCrosshairs&3))
|
switch ((videoShowCrosshairs&3))
|
||||||
{
|
{
|
||||||
case 0: puts("Crosshairs disabled."); break;
|
case 0: puts("Crosshairs disabled."); break;
|
||||||
case 3: puts("Crosshairs enabled."); break;
|
case 3: puts("Crosshairs enabled."); break;
|
||||||
|
|
47
Src/OSD/Video.h
Executable file
47
Src/OSD/Video.h
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
/**
|
||||||
|
** Supermodel
|
||||||
|
** A Sega Model 3 Arcade Emulator.
|
||||||
|
** Copyright 2011 Bart Trzynadlowski, Nik Henson
|
||||||
|
**
|
||||||
|
** This file is part of Supermodel.
|
||||||
|
**
|
||||||
|
** Supermodel is free software: you can redistribute it and/or modify it under
|
||||||
|
** the terms of the GNU General Public License as published by the Free
|
||||||
|
** Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
** any later version.
|
||||||
|
**
|
||||||
|
** Supermodel is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
** more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License along
|
||||||
|
** with Supermodel. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Video.h
|
||||||
|
*
|
||||||
|
* Header file for OS-dependent video functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_VIDEO_H
|
||||||
|
#define INCLUDED_VIDEO_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BeginFrameVideo()
|
||||||
|
*
|
||||||
|
* Called at beginning of rendering of video frame. Can be used by OSD layer to prevent rendering to screen.
|
||||||
|
*
|
||||||
|
* Returns true if emulator should render frame to screen.
|
||||||
|
*/
|
||||||
|
extern bool BeginFrameVideo();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EndFrameVideo()
|
||||||
|
*
|
||||||
|
* Called at end of rendering of video frame. Can be used by OSD layer to overlay graphics on screen.
|
||||||
|
*/
|
||||||
|
extern void EndFrameVideo();
|
||||||
|
|
||||||
|
#endif // INCLUDED_VIDEO_H
|
|
@ -103,6 +103,7 @@
|
||||||
// OSD Interfaces
|
// OSD Interfaces
|
||||||
#include "OSD/Thread.h"
|
#include "OSD/Thread.h"
|
||||||
#include "OSD/Audio.h"
|
#include "OSD/Audio.h"
|
||||||
|
#include "OSD/Video.h"
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -1892,6 +1892,10 @@
|
||||||
RelativePath="..\Src\OSD\Thread.h"
|
RelativePath="..\Src\OSD\Thread.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\Src\OSD\Video.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<Filter
|
<Filter
|
||||||
Name="SDL"
|
Name="SDL"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue