SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
Macros | Functions | Variables
renderer_GL_common.inl File Reference
#include <stdint.h>
#include <stdlib.h>
#include "SDL_platform.h"
#include <math.h>
#include <string.h>
#include "stb_image.h"
#include "stb_image_write.h"

Go to the source code of this file.

Macros

#define GLAPIENTRY
 
#define intptr_t   long
 
#define M_PI   3.14159265358979323846
 
#define static_inline   static inline
 
#define GPU_BLIT_BUFFER_VERTICES_PER_SPRITE   4
 
#define GPU_BLIT_BUFFER_INIT_MAX_NUM_VERTICES   (GPU_BLIT_BUFFER_VERTICES_PER_SPRITE*1000)
 
#define GPU_BLIT_BUFFER_ABSOLUTE_MAX_VERTICES   60000
 
#define GPU_INDEX_BUFFER_ABSOLUTE_MAX_VERTICES   4000000000u
 
#define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX   8
 
#define GPU_BLIT_BUFFER_STRIDE   (sizeof(float)*GPU_BLIT_BUFFER_FLOATS_PER_VERTEX)
 
#define GPU_BLIT_BUFFER_VERTEX_OFFSET   0
 
#define GPU_BLIT_BUFFER_TEX_COORD_OFFSET   2
 
#define GPU_BLIT_BUFFER_COLOR_OFFSET   4
 
#define SDL_Window   SDL_Surface
 
#define GET_ALPHA(sdl_color)   ((sdl_color).unused)
 
#define SDL_GPU_DISABLE_SHADERS
 
#define MIX_COLOR_COMPONENT_NORMALIZED_RESULT(a, b)   ((a)/255.0f * (b)/255.0f)
 
#define MIX_COLOR_COMPONENT(a, b)   (((a)/255.0f * (b)/255.0f)*255)
 
#define SET_TEXTURED_VERTEX(x, y, s, t, r, g, b, a)
 
#define SET_TEXTURED_VERTEX_UNINDEXED(x, y, s, t, r, g, b, a)
 
#define SET_UNTEXTURED_VERTEX(x, y, r, g, b, a)
 
#define SET_UNTEXTURED_VERTEX_UNINDEXED(x, y, r, g, b, a)
 
#define SET_INDEXED_VERTEX(offset)   index_buffer[cdata->index_buffer_num_vertices++] = blit_buffer_starting_index + (offset);
 
#define SET_RELATIVE_INDEXED_VERTEX(offset)   index_buffer[cdata->index_buffer_num_vertices++] = cdata->blit_buffer_num_vertices + (offset);
 
#define BEGIN_UNTEXTURED_SEGMENTS(x1, y1, x2, y2, r, g, b, a)
 
#define SET_UNTEXTURED_SEGMENTS(x1, y1, x2, y2, r, g, b, a)
 
#define LOOP_UNTEXTURED_SEGMENTS()
 
#define END_UNTEXTURED_SEGMENTS(x1, y1, x2, y2, r, g, b, a)
 
#define MAX(a, b)   ((a) > (b)? (a) : (b))
 
#define SET_COMMON_FUNCTIONS(impl)
 

Functions

int gpu_strcasecmp (const char *s1, const char *s2)
 
static_inline SDL_Windowget_window (Uint32 windowID)
 
static_inline Uint32 get_window_id (SDL_Surface *window)
 
static_inline void get_window_dimensions (SDL_Window *window, int *w, int *h)
 
static_inline void get_drawable_dimensions (SDL_Window *window, int *w, int *h)
 
static_inline void resize_window (GPU_Target *target, int w, int h)
 
static_inline GPU_bool get_fullscreen_state (SDL_Window *window)
 
static_inline GPU_bool has_colorkey (SDL_Surface *surface)
 
static_inline void get_target_window_dimensions (GPU_Target *target, int *w, int *h)
 
static_inline void get_target_drawable_dimensions (GPU_Target *target, int *w, int *h)
 
static_inline void fast_upload_texture (const void *pixels, GPU_Rect update_rect, Uint32 format, int alignment, int row_length)
 
static_inline void upload_texture (const void *pixels, GPU_Rect update_rect, Uint32 format, int alignment, int row_length, unsigned int pitch, int bytes_per_pixel)
 
static_inline void upload_new_texture (void *pixels, GPU_Rect update_rect, Uint32 format, int alignment, int row_length, int bytes_per_pixel)
 
static_inline GPU_bool isPowerOfTwo (unsigned int x)
 
static_inline unsigned int getNearestPowerOf2 (unsigned int n)
 
static_inline void flushAndBindTexture (GPU_Renderer *renderer, GLuint handle)
 
static_inline void flushAndBindFramebuffer (GPU_Renderer *renderer, GLuint handle)
 
static_inline void flushBlitBufferIfCurrentTexture (GPU_Renderer *renderer, GPU_Image *image)
 
static_inline void flushAndClearBlitBufferIfCurrentTexture (GPU_Renderer *renderer, GPU_Image *image)
 
static_inline GPU_bool isCurrentTarget (GPU_Renderer *renderer, GPU_Target *target)
 
static_inline void flushAndClearBlitBufferIfCurrentFramebuffer (GPU_Renderer *renderer, GPU_Target *target)
 
static_inline Uint32 getPixel (SDL_Surface *Surface, int x, int y)
 
static_inline void submit_buffer_data (int bytes, float *values, int bytes_indices, unsigned short *indices)
 

Variables

static GLuint framebuffer = glBindFramebufferNOOP
 
static const GLuint * framebuffers = glDeleteFramebuffersNOOP
 
static GLenum attachment
 
static GLenum GLenum textarget
 
static GLenum GLenum GLuint texture
 
static GLenum GLenum GLuint GLint level = glFramebufferTexture2DNOOP
 
static GLuint * ids = glGenFramebuffersNOOP
 

Macro Definition Documentation

◆ BEGIN_UNTEXTURED_SEGMENTS

#define BEGIN_UNTEXTURED_SEGMENTS (   x1,
  y1,
  x2,
  y2,
  r,
  g,
  b,
 
)
Value:
SET_UNTEXTURED_VERTEX(x1, y1, r, g, b, a); \
SET_UNTEXTURED_VERTEX(x2, y2, r, g, b, a);
#define SET_UNTEXTURED_VERTEX(x, y, r, g, b, a)

Definition at line 4031 of file renderer_GL_common.inl.

◆ END_UNTEXTURED_SEGMENTS

#define END_UNTEXTURED_SEGMENTS (   x1,
  y1,
  x2,
  y2,
  r,
  g,
  b,
 
)
Value:
SET_UNTEXTURED_VERTEX(x1, y1, r, g, b, a); \
SET_RELATIVE_INDEXED_VERTEX(-2); \
SET_UNTEXTURED_VERTEX(x2, y2, r, g, b, a); \
SET_RELATIVE_INDEXED_VERTEX(-2);
#define SET_UNTEXTURED_VERTEX(x, y, r, g, b, a)

Definition at line 4051 of file renderer_GL_common.inl.

◆ GET_ALPHA

#define GET_ALPHA (   sdl_color)    ((sdl_color).unused)

Definition at line 151 of file renderer_GL_common.inl.

◆ GLAPIENTRY

#define GLAPIENTRY

Definition at line 8 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_ABSOLUTE_MAX_VERTICES

#define GPU_BLIT_BUFFER_ABSOLUTE_MAX_VERTICES   60000

Definition at line 90 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_COLOR_OFFSET

#define GPU_BLIT_BUFFER_COLOR_OFFSET   4

Definition at line 102 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_FLOATS_PER_VERTEX

#define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX   8

Definition at line 96 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_INIT_MAX_NUM_VERTICES

#define GPU_BLIT_BUFFER_INIT_MAX_NUM_VERTICES   (GPU_BLIT_BUFFER_VERTICES_PER_SPRITE*1000)

Definition at line 86 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_STRIDE

#define GPU_BLIT_BUFFER_STRIDE   (sizeof(float)*GPU_BLIT_BUFFER_FLOATS_PER_VERTEX)

Definition at line 99 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_TEX_COORD_OFFSET

#define GPU_BLIT_BUFFER_TEX_COORD_OFFSET   2

Definition at line 101 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_VERTEX_OFFSET

#define GPU_BLIT_BUFFER_VERTEX_OFFSET   0

Definition at line 100 of file renderer_GL_common.inl.

◆ GPU_BLIT_BUFFER_VERTICES_PER_SPRITE

#define GPU_BLIT_BUFFER_VERTICES_PER_SPRITE   4

Definition at line 85 of file renderer_GL_common.inl.

◆ GPU_INDEX_BUFFER_ABSOLUTE_MAX_VERTICES

#define GPU_INDEX_BUFFER_ABSOLUTE_MAX_VERTICES   4000000000u

Definition at line 92 of file renderer_GL_common.inl.

◆ intptr_t

#define intptr_t   long

Definition at line 23 of file renderer_GL_common.inl.

◆ LOOP_UNTEXTURED_SEGMENTS

#define LOOP_UNTEXTURED_SEGMENTS ( )
Value:
SET_RELATIVE_INDEXED_VERTEX(-1); \
SET_INDEXED_VERTEX(1); \
SET_INDEXED_VERTEX(0);
#define SET_INDEXED_VERTEX(offset)

Definition at line 4045 of file renderer_GL_common.inl.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 30 of file renderer_GL_common.inl.

◆ MAX

#define MAX (   a,
 
)    ((a) > (b)? (a) : (b))

Definition at line 5539 of file renderer_GL_common.inl.

◆ MIX_COLOR_COMPONENT

#define MIX_COLOR_COMPONENT (   a,
 
)    (((a)/255.0f * (b)/255.0f)*255)

Definition at line 988 of file renderer_GL_common.inl.

◆ MIX_COLOR_COMPONENT_NORMALIZED_RESULT

#define MIX_COLOR_COMPONENT_NORMALIZED_RESULT (   a,
 
)    ((a)/255.0f * (b)/255.0f)

Definition at line 987 of file renderer_GL_common.inl.

◆ SDL_GPU_DISABLE_SHADERS

#define SDL_GPU_DISABLE_SHADERS

Definition at line 223 of file renderer_GL_common.inl.

◆ SDL_Window

#define SDL_Window   SDL_Surface

Definition at line 150 of file renderer_GL_common.inl.

◆ SET_COMMON_FUNCTIONS

#define SET_COMMON_FUNCTIONS (   impl)

Definition at line 6761 of file renderer_GL_common.inl.

◆ SET_INDEXED_VERTEX

#define SET_INDEXED_VERTEX (   offset)    index_buffer[cdata->index_buffer_num_vertices++] = blit_buffer_starting_index + (offset);

Definition at line 4023 of file renderer_GL_common.inl.

◆ SET_RELATIVE_INDEXED_VERTEX

#define SET_RELATIVE_INDEXED_VERTEX (   offset)    index_buffer[cdata->index_buffer_num_vertices++] = cdata->blit_buffer_num_vertices + (offset);

Definition at line 4026 of file renderer_GL_common.inl.

◆ SET_TEXTURED_VERTEX

#define SET_TEXTURED_VERTEX (   x,
  y,
  s,
  t,
  r,
  g,
  b,
 
)
Value:
blit_buffer[vert_index] = x; \
blit_buffer[vert_index+1] = y; \
blit_buffer[tex_index] = s; \
blit_buffer[tex_index+1] = t; \
blit_buffer[color_index] = r; \
blit_buffer[color_index+1] = g; \
blit_buffer[color_index+2] = b; \
blit_buffer[color_index+3] = a; \
index_buffer[cdata->index_buffer_num_vertices++] = cdata->blit_buffer_num_vertices++; \
#define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX

Definition at line 3975 of file renderer_GL_common.inl.

◆ SET_TEXTURED_VERTEX_UNINDEXED

#define SET_TEXTURED_VERTEX_UNINDEXED (   x,
  y,
  s,
  t,
  r,
  g,
  b,
 
)
Value:
blit_buffer[vert_index] = x; \
blit_buffer[vert_index+1] = y; \
blit_buffer[tex_index] = s; \
blit_buffer[tex_index+1] = t; \
blit_buffer[color_index] = r; \
blit_buffer[color_index+1] = g; \
blit_buffer[color_index+2] = b; \
blit_buffer[color_index+3] = a; \
#define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX

Definition at line 3989 of file renderer_GL_common.inl.

◆ SET_UNTEXTURED_SEGMENTS

#define SET_UNTEXTURED_SEGMENTS (   x1,
  y1,
  x2,
  y2,
  r,
  g,
  b,
 
)
Value:
SET_UNTEXTURED_VERTEX(x1, y1, r, g, b, a); \
SET_RELATIVE_INDEXED_VERTEX(-2); \
SET_UNTEXTURED_VERTEX(x2, y2, r, g, b, a); \
SET_RELATIVE_INDEXED_VERTEX(-2); \
SET_RELATIVE_INDEXED_VERTEX(-2); \
SET_RELATIVE_INDEXED_VERTEX(-1);
#define SET_UNTEXTURED_VERTEX(x, y, r, g, b, a)

Definition at line 4036 of file renderer_GL_common.inl.

◆ SET_UNTEXTURED_VERTEX

#define SET_UNTEXTURED_VERTEX (   x,
  y,
  r,
  g,
  b,
 
)
Value:
blit_buffer[vert_index] = x; \
blit_buffer[vert_index+1] = y; \
blit_buffer[color_index] = r; \
blit_buffer[color_index+1] = g; \
blit_buffer[color_index+2] = b; \
blit_buffer[color_index+3] = a; \
index_buffer[cdata->index_buffer_num_vertices++] = cdata->blit_buffer_num_vertices++; \
#define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX

Definition at line 4002 of file renderer_GL_common.inl.

◆ SET_UNTEXTURED_VERTEX_UNINDEXED

#define SET_UNTEXTURED_VERTEX_UNINDEXED (   x,
  y,
  r,
  g,
  b,
 
)
Value:
blit_buffer[vert_index] = x; \
blit_buffer[vert_index+1] = y; \
blit_buffer[color_index] = r; \
blit_buffer[color_index+1] = g; \
blit_buffer[color_index+2] = b; \
blit_buffer[color_index+3] = a; \
#define GPU_BLIT_BUFFER_FLOATS_PER_VERTEX

Definition at line 4013 of file renderer_GL_common.inl.

◆ static_inline

#define static_inline   static inline

Definition at line 38 of file renderer_GL_common.inl.

Function Documentation

◆ fast_upload_texture()

static_inline void fast_upload_texture ( const void *  pixels,
GPU_Rect  update_rect,
Uint32  format,
int  alignment,
int  row_length 
)

Definition at line 273 of file renderer_GL_common.inl.

◆ flushAndBindFramebuffer()

static_inline void flushAndBindFramebuffer ( GPU_Renderer renderer,
GLuint  handle 
)

Definition at line 651 of file renderer_GL_common.inl.

◆ flushAndBindTexture()

static_inline void flushAndBindTexture ( GPU_Renderer renderer,
GLuint  handle 
)

Definition at line 611 of file renderer_GL_common.inl.

◆ flushAndClearBlitBufferIfCurrentFramebuffer()

static_inline void flushAndClearBlitBufferIfCurrentFramebuffer ( GPU_Renderer renderer,
GPU_Target target 
)

Definition at line 683 of file renderer_GL_common.inl.

◆ flushAndClearBlitBufferIfCurrentTexture()

static_inline void flushAndClearBlitBufferIfCurrentTexture ( GPU_Renderer renderer,
GPU_Image image 
)

Definition at line 668 of file renderer_GL_common.inl.

◆ flushBlitBufferIfCurrentTexture()

static_inline void flushBlitBufferIfCurrentTexture ( GPU_Renderer renderer,
GPU_Image image 
)

Definition at line 660 of file renderer_GL_common.inl.

◆ get_drawable_dimensions()

static_inline void get_drawable_dimensions ( SDL_Window window,
int *  w,
int *  h 
)

Definition at line 171 of file renderer_GL_common.inl.

◆ get_fullscreen_state()

static_inline GPU_bool get_fullscreen_state ( SDL_Window window)

Definition at line 186 of file renderer_GL_common.inl.

◆ get_target_drawable_dimensions()

static_inline void get_target_drawable_dimensions ( GPU_Target target,
int *  w,
int *  h 
)

Definition at line 209 of file renderer_GL_common.inl.

◆ get_target_window_dimensions()

static_inline void get_target_window_dimensions ( GPU_Target target,
int *  w,
int *  h 
)

Definition at line 200 of file renderer_GL_common.inl.

◆ get_window()

static_inline SDL_Window* get_window ( Uint32  windowID)

Definition at line 153 of file renderer_GL_common.inl.

◆ get_window_dimensions()

static_inline void get_window_dimensions ( SDL_Window window,
int *  w,
int *  h 
)

Definition at line 163 of file renderer_GL_common.inl.

◆ get_window_id()

static_inline Uint32 get_window_id ( SDL_Surface *  window)

Definition at line 158 of file renderer_GL_common.inl.

◆ getNearestPowerOf2()

static_inline unsigned int getNearestPowerOf2 ( unsigned int  n)

Definition at line 588 of file renderer_GL_common.inl.

◆ getPixel()

static_inline Uint32 getPixel ( SDL_Surface *  Surface,
int  x,
int  y 
)

Definition at line 3653 of file renderer_GL_common.inl.

◆ gpu_strcasecmp()

int gpu_strcasecmp ( const char *  s1,
const char *  s2 
)

Definition at line 2512 of file SDL_gpu.c.

◆ has_colorkey()

static_inline GPU_bool has_colorkey ( SDL_Surface *  surface)

Definition at line 191 of file renderer_GL_common.inl.

◆ isCurrentTarget()

static_inline GPU_bool isCurrentTarget ( GPU_Renderer renderer,
GPU_Target target 
)

Definition at line 677 of file renderer_GL_common.inl.

◆ isPowerOfTwo()

static_inline GPU_bool isPowerOfTwo ( unsigned int  x)

Definition at line 583 of file renderer_GL_common.inl.

◆ resize_window()

static_inline void resize_window ( GPU_Target target,
int  w,
int  h 
)

Definition at line 176 of file renderer_GL_common.inl.

◆ submit_buffer_data()

static_inline void submit_buffer_data ( int  bytes,
float *  values,
int  bytes_indices,
unsigned short *  indices 
)

Definition at line 4623 of file renderer_GL_common.inl.

◆ upload_new_texture()

static_inline void upload_new_texture ( void *  pixels,
GPU_Rect  update_rect,
Uint32  format,
int  alignment,
int  row_length,
int  bytes_per_pixel 
)

Definition at line 349 of file renderer_GL_common.inl.

◆ upload_texture()

static_inline void upload_texture ( const void *  pixels,
GPU_Rect  update_rect,
Uint32  format,
int  alignment,
int  row_length,
unsigned int  pitch,
int  bytes_per_pixel 
)

Definition at line 336 of file renderer_GL_common.inl.

Variable Documentation

◆ attachment

GLenum attachment

Definition at line 403 of file renderer_GL_common.inl.

◆ framebuffer

GLuint framebuffer = glBindFramebufferNOOP

Definition at line 400 of file renderer_GL_common.inl.

◆ framebuffers

const GLuint* framebuffers = glDeleteFramebuffersNOOP

Definition at line 402 of file renderer_GL_common.inl.

◆ ids

GLuint* ids = glGenFramebuffersNOOP

Definition at line 404 of file renderer_GL_common.inl.

◆ level

GLenum GLenum GLuint GLint level = glFramebufferTexture2DNOOP

Definition at line 403 of file renderer_GL_common.inl.

◆ textarget

GLenum GLenum textarget

Definition at line 403 of file renderer_GL_common.inl.

◆ texture

GLenum GLenum GLuint texture

Definition at line 403 of file renderer_GL_common.inl.