102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
backend_opengl.c File Reference
#include "backend_opengl_private.h"
#include "graphics_private.h"
#include <dttr_log.h>
#include <dttr_config.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "gen/opengl_shaders.h"

Go to the source code of this file.

Macros

#define DRIVER_DISPLAY_OPENGL   "OpenGL 3.3"

Functions

static GLuint compile_shader (GLenum type, const char *source)
static GLuint create_program ()
static bool create_fbo (opengl_backend_data *gl, int width, int height)
static void destroy_fbo (opengl_backend_data *gl)
static void create_samplers (opengl_backend_data *gl)
static int select_gl_msaa_samples ()
static bool create_msaa_fbo (opengl_backend_data *gl, int w, int h, int samples)
static void destroy_msaa_fbo (opengl_backend_data *gl)
static void release_deferred_gl_destroys (DTTR_BackendState *state, opengl_backend_data *gl)
static void defer_texture_destroy (DTTR_BackendState *state, int texture_index)
bool dttr_graphics_opengl_init (DTTR_BackendState *state)
static bool resize_fbo (DTTR_BackendState *state, int width, int height)
static void upload_pending_textures_gl (DTTR_BackendState *state, opengl_backend_data *gl)
static void upload_video_texture (opengl_backend_data *gl, const uint8_t *pixels, int width, int height)
static void begin_frame (DTTR_BackendState *state)
static void replay_batch_records_gl (DTTR_BackendState *state, opengl_backend_data *gl)
static void end_frame (DTTR_BackendState *state)
static bool present_video_frame_bgra (DTTR_BackendState *state, const uint8_t *pixels, int width, int height, int stride)
static void cleanup (DTTR_BackendState *state)
static const char * get_driver_name (const DTTR_BackendState *state)

Variables

static const DTTR_RendererVtbl renderer

Macro Definition Documentation

◆ DRIVER_DISPLAY_OPENGL

#define DRIVER_DISPLAY_OPENGL   "OpenGL 3.3"

Definition at line 11 of file backend_opengl.c.

Referenced by get_driver_name().

Function Documentation

◆ begin_frame()

◆ cleanup()

◆ compile_shader()

GLuint compile_shader ( GLenum type,
const char * source )
static

Definition at line 26 of file backend_opengl.c.

References DTTR_LOG_ERROR, NULL, source, and type.

Referenced by create_program().

◆ create_fbo()

◆ create_msaa_fbo()

◆ create_program()

GLuint create_program ( )
static

Definition at line 49 of file backend_opengl.c.

References compile_shader(), DTTR_LOG_ERROR, and NULL.

Referenced by dttr_graphics_opengl_init().

◆ create_samplers()

void create_samplers ( opengl_backend_data * gl)
static

◆ defer_texture_destroy()

◆ destroy_fbo()

◆ destroy_msaa_fbo()

◆ dttr_graphics_opengl_init()

◆ end_frame()

◆ get_driver_name()

const char * get_driver_name ( const DTTR_BackendState * state)
static

Definition at line 951 of file backend_opengl.c.

References DRIVER_DISPLAY_OPENGL, and state.

◆ present_video_frame_bgra()

◆ release_deferred_gl_destroys()

void release_deferred_gl_destroys ( DTTR_BackendState * state,
opengl_backend_data * gl )
static

◆ replay_batch_records_gl()

void replay_batch_records_gl ( DTTR_BackendState * state,
opengl_backend_data * gl )
static

Definition at line 573 of file backend_opengl.c.

References DTTR_Uniforms::alpha_arg1, DTTR_Uniforms::alpha_arg2, DTTR_Uniforms::alpha_op, DTTR_BatchRecord::blend_mode, DTTR_BatchRecord::clear, DTTR_BatchRecord::color, DTTR_Uniforms::color_arg1, DTTR_Uniforms::color_arg2, DTTR_Uniforms::color_op, DTTR_BatchRecord::depth, DTTR_BatchRecord::depth_test, DTTR_BatchRecord::depth_write, DTTR_BatchRecord::draw, DTTR_BATCH_CLEAR, DTTR_BLEND_ADDITIVE, DTTR_BLEND_OFF, DTTR_CLEAR_COLOR, DTTR_CLEAR_DEPTH, DTTR_MAX_STAGED_TEXTURES, opengl_backend_data::dummy_texture, opengl_backend_data::fbo, opengl_backend_data::fbo_height, opengl_backend_data::fbo_width, DTTR_BatchRecord::first_vertex, DTTR_BatchRecord::flags, opengl_backend_data::gl_samplers, opengl_backend_data::gl_textures, DTTR_Uniforms::has_texture, DTTR_Uniforms::is_2d, opengl_backend_data::loc_alpha_arg1, opengl_backend_data::loc_alpha_arg2, opengl_backend_data::loc_alpha_op, opengl_backend_data::loc_color_arg1, opengl_backend_data::loc_color_arg2, opengl_backend_data::loc_color_op, opengl_backend_data::loc_has_texture, opengl_backend_data::loc_is_2d, opengl_backend_data::loc_mvp, opengl_backend_data::loc_screen_size, opengl_backend_data::loc_texture, opengl_backend_data::msaa_fbo, opengl_backend_data::msaa_samples, DTTR_Uniforms::mvp, opengl_backend_data::program, DTTR_BatchRecord::sampler_index, DTTR_Uniforms::screen_size, state, DTTR_BatchRecord::texture_index, DTTR_BatchRecord::type, DTTR_BatchRecord::uniforms, opengl_backend_data::vao, and DTTR_BatchRecord::vertex_count.

Referenced by end_frame().

◆ resize_fbo()

◆ select_gl_msaa_samples()

int select_gl_msaa_samples ( )
static

Definition at line 172 of file backend_opengl.c.

References dttr_config.

Referenced by dttr_graphics_opengl_init().

◆ upload_pending_textures_gl()

◆ upload_video_texture()

void upload_video_texture ( opengl_backend_data * gl,
const uint8_t * pixels,
int width,
int height )
static

Variable Documentation

◆ renderer

const DTTR_RendererVtbl renderer
static
Initial value:
= {
.begin_frame = begin_frame,
.end_frame = end_frame,
.present_video_frame_bgra = present_video_frame_bgra,
.resize = resize_fbo,
.cleanup = cleanup,
.get_driver_name = get_driver_name,
.defer_texture_destroy = defer_texture_destroy,
}
static void defer_texture_destroy(DTTR_BackendState *state, int texture_index)
static void begin_frame(DTTR_BackendState *state)
static const char * get_driver_name(const DTTR_BackendState *state)
static void end_frame(DTTR_BackendState *state)
static bool resize_fbo(DTTR_BackendState *state, int width, int height)
static void cleanup(DTTR_BackendState *state)
static bool present_video_frame_bgra(DTTR_BackendState *state, const uint8_t *pixels, int width, int height, int stride)

Definition at line 22 of file backend_opengl.c.

Referenced by dttr_graphics_opengl_init(), and dttr_graphics_sdl3gpu_init().