hwr2: Create hwr2 instance, call Present to flip

This commit is contained in:
Eidolon 2022-08-01 19:36:45 -05:00
parent 0baa2c2843
commit c877518185
3 changed files with 75 additions and 3 deletions

View file

@ -84,6 +84,8 @@
#include "hwsym_sdl.h"
#include "ogl_sdl.h"
#endif
#include "i_video_hwr2.h"
#include "../hwr2/renderer.h"
// maximum number of windowed modes (see windowedModes[][])
#define MAXWINMODES (18)
@ -147,6 +149,7 @@ SDL_Window *window;
SDL_Renderer *renderer;
static SDL_Texture *texture;
static SDL_bool havefocus = SDL_TRUE;
static hwr2renderer_h sdl_current_hwr2renderer;
static const char *fallback_resolution_name = "Fallback";
// windowed video modes from which to choose from.
@ -233,6 +236,14 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool
OglSdlSurface(vid.width, vid.height);
}
#endif
if (rendermode == render_hwr2)
{
if (sdl_current_hwr2renderer == NULL)
{
I_SDL_DestroyGlesHwr2Renderer(sdl_current_hwr2renderer);
}
sdl_current_hwr2renderer = I_SDL_CreateGlesHwr2Renderer(window);
}
if (rendermode == render_soft)
{
@ -1168,6 +1179,10 @@ void I_UpdateNoBlit(void)
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
}
else if (rendermode == render_hwr2)
{
I_SDL_Hwr2Present(sdl_current_hwr2renderer);
}
}
exposevideo = SDL_FALSE;
}
@ -1257,6 +1272,10 @@ void I_FinishUpdate(void)
OglSdlFinishUpdate(cv_vidwait.value);
}
#endif
else if (rendermode == render_hwr2)
{
I_SDL_Hwr2Present(sdl_current_hwr2renderer);
}
exposevideo = SDL_FALSE;
}
@ -1956,3 +1975,8 @@ void I_GetCursorPosition(INT32 *x, INT32 *y)
{
SDL_GetMouseState(x, y);
}
hwr2renderer_h I_GetHwr2Renderer()
{
return sdl_current_hwr2renderer;
}

View file

@ -1,3 +1,7 @@
#include "i_video_hwr2.h"
#include "SDL.h"
extern "C" {
#include "../i_video.h"
}
@ -6,12 +10,29 @@ extern "C" {
class Sdl2Gles2Renderer : public Gles2Renderer
{
private:
SDL_Window* window_ = NULL;
public:
Sdl2Gles2Renderer(SDL_Window* window) : window_(window) {}
virtual void Present()
{}
{
SDL_GL_SwapWindow(window_);
}
};
hwr2renderer_h I_GetHwr2Renderer()
hwr2renderer_h I_SDL_CreateGlesHwr2Renderer(SDL_Window* window)
{
return reinterpret_cast<hwr2renderer_h>(new Sdl2Gles2Renderer());
return reinterpret_cast<hwr2renderer_h>(new Sdl2Gles2Renderer(window));
}
void I_SDL_DestroyGlesHwr2Renderer(hwr2renderer_h renderer)
{
delete reinterpret_cast<Sdl2Gles2Renderer*>(renderer);
}
void I_SDL_Hwr2Present(hwr2renderer_h renderer)
{
Sdl2Gles2Renderer* hwr2 = reinterpret_cast<Sdl2Gles2Renderer*>(renderer);
hwr2->Present();
}

27
src/sdl/i_video_hwr2.h Normal file
View file

@ -0,0 +1,27 @@
#ifndef __SDL_I_VIDEO_HWR2_H__
#define __SDL_I_VIDEO_HWR2_H__
#include "SDL.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "../i_video.h"
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
hwr2renderer_h I_SDL_CreateGlesHwr2Renderer(SDL_Window* window);
void I_SDL_DestroyGlesHwr2Renderer(hwr2renderer_h renderer);
void I_SDL_Hwr2Present(hwr2renderer_h renderer);
#ifdef __cplusplus
}
#endif
#endif // __SDL_I_VIDEO_HWR2_H__