Skip to content

Commit

Permalink
cleanup rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
walkawayy committed Jan 22, 2025
1 parent 19a7533 commit 9efa753
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
16 changes: 9 additions & 7 deletions src/libtrx/gfx/renderers/fbo_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void M_Reset(GFX_RENDERER *renderer);

static void M_Render(GFX_RENDERER *renderer);
static void M_Bind(const GFX_RENDERER *renderer);
static void M_Unbind(const GFX_RENDERER *renderer);
static void M_Unbind(void);

static void M_SwapBuffers(GFX_RENDERER *renderer)
{
Expand All @@ -50,7 +50,7 @@ static void M_SwapBuffers(GFX_RENDERER *renderer)
GFX_Context_SwitchToWindowViewportAR();
M_Render(renderer);

M_Unbind(renderer);
M_Unbind();
SDL_GL_SwapWindow(GFX_Context_GetWindowHandle());

GFX_Context_SwitchToWindowViewport();
Expand All @@ -75,14 +75,16 @@ static void M_Init(GFX_RENDERER *const renderer, const GFX_CONFIG *const config)
int32_t fbo_width = GFX_Context_GetDisplayWidth();
int32_t fbo_height = GFX_Context_GetDisplayHeight();

GFX_GL_VertexArray_Init(&priv->vertex_array);
GFX_GL_Buffer_Init(&priv->buffer, GL_ARRAY_BUFFER);

GFX_GL_VertexArray_Bind(&priv->vertex_array);
GFX_GL_Buffer_Bind(&priv->buffer);

GLfloat verts[] = { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0,
0.0, 1.0, 1.0, 0.0, 1.0, 1.0 };
GFX_GL_Buffer_Data(&priv->buffer, sizeof(verts), verts, GL_STATIC_DRAW);

GFX_GL_VertexArray_Init(&priv->vertex_array);
GFX_GL_VertexArray_Bind(&priv->vertex_array);
GFX_GL_VertexArray_Attribute(
&priv->vertex_array, 0, 2, GL_FLOAT, GL_FALSE, 0, 0);

Expand Down Expand Up @@ -193,12 +195,12 @@ static void M_Render(GFX_RENDERER *renderer)
: GL_NEAREST;

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
M_Bind(renderer);
GFX_GL_CheckError();

GFX_GL_Program_Bind(&priv->program);
GFX_GL_Buffer_Bind(&priv->buffer);
GFX_GL_VertexArray_Bind(&priv->vertex_array);
GFX_GL_Buffer_Bind(&priv->buffer);
glActiveTexture(GL_TEXTURE0);
GFX_GL_Texture_Bind(&priv->texture);

Expand Down Expand Up @@ -240,7 +242,7 @@ static void M_Bind(const GFX_RENDERER *renderer)
glBindFramebuffer(GL_FRAMEBUFFER, priv->fbo);
}

static void M_Unbind(const GFX_RENDERER *renderer)
static void M_Unbind(void)
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
Expand Down
45 changes: 23 additions & 22 deletions src/tr1/specific/s_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static void M_SetWindowPos(int32_t x, int32_t y, bool update);
static void M_SetWindowSize(int32_t width, int32_t height, bool update);
static void M_SetWindowMaximized(bool is_enabled, bool update);
static void M_SetFullscreen(bool is_enabled, bool update);
static void M_SetGLBackend(const GFX_GL_BACKEND backend);

static void M_HandleQuit(void)
{
Expand Down Expand Up @@ -105,6 +106,28 @@ static void M_SetFullscreen(bool is_enabled, bool update)
}
}

static void M_SetGLBackend(const GFX_GL_BACKEND backend)
{
switch (backend) {
case GFX_GL_21:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0);
break;

case GFX_GL_33C:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(
SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
break;

case GFX_GL_INVALID_BACKEND:
ASSERT_FAIL();
break;
}
}

void S_Shell_ToggleFullscreen(void)
{
M_SetFullscreen(!g_Config.window.is_fullscreen, true);
Expand Down Expand Up @@ -243,28 +266,6 @@ int main(int argc, char **argv)
return 0;
}

static void M_SetGLBackend(const GFX_GL_BACKEND backend)
{
switch (backend) {
case GFX_GL_21:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0);
break;

case GFX_GL_33C:
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(
SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
break;

case GFX_GL_INVALID_BACKEND:
ASSERT_FAIL();
break;
}
}

void S_Shell_CreateWindow(void)
{
SDL_Window *const window = SDL_CreateWindow(
Expand Down
4 changes: 2 additions & 2 deletions src/tr2/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,8 @@ int32_t Output_GetObjectBounds(const BOUNDS_16 *const bounds)
return 0;
}

constexpr int32_t vtx_count = 8;
const XYZ_32 vtx[vtx_count] = {
const int32_t vtx_count = 8;
const XYZ_32 vtx[] = {
{ .x = bounds->min.x, .y = bounds->min.y, .z = bounds->min.z },
{ .x = bounds->max.x, .y = bounds->min.y, .z = bounds->min.z },
{ .x = bounds->max.x, .y = bounds->max.y, .z = bounds->min.z },
Expand Down
1 change: 1 addition & 0 deletions src/tr2/game/render/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static struct {
static RENDERER *M_GetRenderer(void);
static void M_ReuploadBackground(void);
static void M_ResetPolyList(void);
static void M_SetGLBackend(const GFX_GL_BACKEND backend);

static RENDERER *M_GetRenderer(void)
{
Expand Down

0 comments on commit 9efa753

Please sign in to comment.