SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
SDL_gpu_RendererImpl.h
Go to the documentation of this file.
1 #ifndef _GPU_RENDERERIMPL_H__
2 #define _GPU_RENDERERIMPL_H__
3 
4 #include "SDL_gpu.h"
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 // Internal API for managing window mappings
11 DECLSPEC void SDLCALL GPU_AddWindowMapping(GPU_Target* target);
12 DECLSPEC void SDLCALL GPU_RemoveWindowMapping(Uint32 windowID);
13 DECLSPEC void SDLCALL GPU_RemoveWindowMappingByTarget(GPU_Target* target);
14 
16 typedef struct GPU_RendererImpl
17 {
22  GPU_Target* (SDLCALL *Init)(GPU_Renderer* renderer, GPU_RendererID renderer_request, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags);
23 
26  GPU_Target* (SDLCALL *CreateTargetFromWindow)(GPU_Renderer* renderer, Uint32 windowID, GPU_Target* target);
27 
29  GPU_Target* (SDLCALL *CreateAliasTarget)(GPU_Renderer* renderer, GPU_Target* target);
30 
32  void (SDLCALL *MakeCurrent)(GPU_Renderer* renderer, GPU_Target* target, Uint32 windowID);
33 
35  void (SDLCALL *SetAsCurrent)(GPU_Renderer* renderer);
36 
38  void (SDLCALL *ResetRendererState)(GPU_Renderer* renderer);
39 
41  GPU_bool (SDLCALL *SetWindowResolution)(GPU_Renderer* renderer, Uint16 w, Uint16 h);
42 
44  void (SDLCALL *SetVirtualResolution)(GPU_Renderer* renderer, GPU_Target* target, Uint16 w, Uint16 h);
45 
47  void (SDLCALL *UnsetVirtualResolution)(GPU_Renderer* renderer, GPU_Target* target);
48 
50  void (SDLCALL *Quit)(GPU_Renderer* renderer);
51 
54 
56  GPU_Camera (SDLCALL *SetCamera)(GPU_Renderer* renderer, GPU_Target* target, GPU_Camera* cam);
57 
59  GPU_Image* (SDLCALL *CreateImage)(GPU_Renderer* renderer, Uint16 w, Uint16 h, GPU_FormatEnum format);
60 
62  GPU_Image* (SDLCALL *CreateImageUsingTexture)(GPU_Renderer* renderer, Uint32 handle, GPU_bool take_ownership);
63 
65  GPU_Image* (SDLCALL *CreateAliasImage)(GPU_Renderer* renderer, GPU_Image* image);
66 
68  GPU_bool (SDLCALL *SaveImage)(GPU_Renderer* renderer, GPU_Image* image, const char* filename, GPU_FileFormatEnum format);
69 
71  GPU_Image* (SDLCALL *CopyImage)(GPU_Renderer* renderer, GPU_Image* image);
72 
74  void (SDLCALL *UpdateImage)(GPU_Renderer* renderer, GPU_Image* image, const GPU_Rect* image_rect, SDL_Surface* surface, const GPU_Rect* surface_rect);
75 
77  void (SDLCALL *UpdateImageBytes)(GPU_Renderer* renderer, GPU_Image* image, const GPU_Rect* image_rect, const unsigned char* bytes, int bytes_per_row);
78 
80  GPU_bool (SDLCALL *ReplaceImage)(GPU_Renderer* renderer, GPU_Image* image, SDL_Surface* surface, const GPU_Rect* surface_rect);
81 
83  GPU_Image* (SDLCALL *CopyImageFromSurface)(GPU_Renderer* renderer, SDL_Surface* surface);
84 
86  GPU_Image* (SDLCALL *CopyImageFromTarget)(GPU_Renderer* renderer, GPU_Target* target);
87 
89  SDL_Surface* (SDLCALL *CopySurfaceFromTarget)(GPU_Renderer* renderer, GPU_Target* target);
90 
92  SDL_Surface* (SDLCALL *CopySurfaceFromImage)(GPU_Renderer* renderer, GPU_Image* image);
93 
95  void (SDLCALL *FreeImage)(GPU_Renderer* renderer, GPU_Image* image);
96 
98  GPU_Target* (SDLCALL *GetTarget)(GPU_Renderer* renderer, GPU_Image* image);
99 
101  void (SDLCALL *FreeTarget)(GPU_Renderer* renderer, GPU_Target* target);
102 
104  void (SDLCALL *Blit)(GPU_Renderer* renderer, GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y);
105 
107  void (SDLCALL *BlitRotate)(GPU_Renderer* renderer, GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees);
108 
110  void (SDLCALL *BlitScale)(GPU_Renderer* renderer, GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float scaleX, float scaleY);
111 
113  void (SDLCALL *BlitTransform)(GPU_Renderer* renderer, GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees, float scaleX, float scaleY);
114 
116  void (SDLCALL *BlitTransformX)(GPU_Renderer* renderer, GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float pivot_x, float pivot_y, float degrees, float scaleX, float scaleY);
117 
119  void (SDLCALL *TriangleBatchX)(GPU_Renderer* renderer, GPU_Image* image, GPU_Target* target, unsigned short num_vertices, void* values, unsigned int num_indices, unsigned short* indices, GPU_BatchFlagEnum flags);
120 
122  void (SDLCALL *GenerateMipmaps)(GPU_Renderer* renderer, GPU_Image* image);
123 
125  GPU_Rect (SDLCALL *SetClip)(GPU_Renderer* renderer, GPU_Target* target, Sint16 x, Sint16 y, Uint16 w, Uint16 h);
126 
128  void (SDLCALL *UnsetClip)(GPU_Renderer* renderer, GPU_Target* target);
129 
131  SDL_Color (SDLCALL *GetPixel)(GPU_Renderer* renderer, GPU_Target* target, Sint16 x, Sint16 y);
132 
134  void (SDLCALL *SetImageFilter)(GPU_Renderer* renderer, GPU_Image* image, GPU_FilterEnum filter);
135 
138 
140  void (SDLCALL *ClearRGBA)(GPU_Renderer* renderer, GPU_Target* target, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
142  void (SDLCALL *FlushBlitBuffer)(GPU_Renderer* renderer);
144  void (SDLCALL *Flip)(GPU_Renderer* renderer, GPU_Target* target);
145 
146 
148  Uint32 (SDLCALL *CreateShaderProgram)(GPU_Renderer* renderer);
149 
151  void (SDLCALL *FreeShaderProgram)(GPU_Renderer* renderer, Uint32 program_object);
152 
154  Uint32 (SDLCALL *CompileShader_RW)(GPU_Renderer* renderer, GPU_ShaderEnum shader_type, SDL_RWops* shader_source, GPU_bool free_rwops);
155 
157  Uint32 (SDLCALL *CompileShader)(GPU_Renderer* renderer, GPU_ShaderEnum shader_type, const char* shader_source);
158 
160  void (SDLCALL *FreeShader)(GPU_Renderer* renderer, Uint32 shader_object);
161 
163  void (SDLCALL *AttachShader)(GPU_Renderer* renderer, Uint32 program_object, Uint32 shader_object);
164 
166  void (SDLCALL *DetachShader)(GPU_Renderer* renderer, Uint32 program_object, Uint32 shader_object);
167 
169  GPU_bool (SDLCALL *LinkShaderProgram)(GPU_Renderer* renderer, Uint32 program_object);
170 
172  void (SDLCALL *ActivateShaderProgram)(GPU_Renderer* renderer, Uint32 program_object, GPU_ShaderBlock* block);
173 
175  void (SDLCALL *DeactivateShaderProgram)(GPU_Renderer* renderer);
176 
178  const char* (SDLCALL *GetShaderMessage)(GPU_Renderer* renderer);
179 
181  int (SDLCALL *GetAttributeLocation)(GPU_Renderer* renderer, Uint32 program_object, const char* attrib_name);
182 
184  int (SDLCALL *GetUniformLocation)(GPU_Renderer* renderer, Uint32 program_object, const char* uniform_name);
185 
187  GPU_ShaderBlock (SDLCALL *LoadShaderBlock)(GPU_Renderer* renderer, Uint32 program_object, const char* position_name, const char* texcoord_name, const char* color_name, const char* modelViewMatrix_name);
188 
190  void (SDLCALL *SetShaderBlock)(GPU_Renderer* renderer, GPU_ShaderBlock block);
191 
193  void (SDLCALL *SetShaderImage)(GPU_Renderer* renderer, GPU_Image* image, int location, int image_unit);
194 
196  void (SDLCALL *GetUniformiv)(GPU_Renderer* renderer, Uint32 program_object, int location, int* values);
197 
199  void (SDLCALL *SetUniformi)(GPU_Renderer* renderer, int location, int value);
200 
202  void (SDLCALL *SetUniformiv)(GPU_Renderer* renderer, int location, int num_elements_per_value, int num_values, int* values);
203 
205  void (SDLCALL *GetUniformuiv)(GPU_Renderer* renderer, Uint32 program_object, int location, unsigned int* values);
206 
208  void (SDLCALL *SetUniformui)(GPU_Renderer* renderer, int location, unsigned int value);
209 
211  void (SDLCALL *SetUniformuiv)(GPU_Renderer* renderer, int location, int num_elements_per_value, int num_values, unsigned int* values);
212 
214  void (SDLCALL *GetUniformfv)(GPU_Renderer* renderer, Uint32 program_object, int location, float* values);
215 
217  void (SDLCALL *SetUniformf)(GPU_Renderer* renderer, int location, float value);
218 
220  void (SDLCALL *SetUniformfv)(GPU_Renderer* renderer, int location, int num_elements_per_value, int num_values, float* values);
221 
223  void (SDLCALL *SetUniformMatrixfv)(GPU_Renderer* renderer, int location, int num_matrices, int num_rows, int num_columns, GPU_bool transpose, float* values);
224 
226  void (SDLCALL *SetAttributef)(GPU_Renderer* renderer, int location, float value);
227 
229  void (SDLCALL *SetAttributei)(GPU_Renderer* renderer, int location, int value);
230 
232  void (SDLCALL *SetAttributeui)(GPU_Renderer* renderer, int location, unsigned int value);
233 
235  void (SDLCALL *SetAttributefv)(GPU_Renderer* renderer, int location, int num_elements, float* value);
236 
238  void (SDLCALL *SetAttributeiv)(GPU_Renderer* renderer, int location, int num_elements, int* value);
239 
241  void (SDLCALL *SetAttributeuiv)(GPU_Renderer* renderer, int location, int num_elements, unsigned int* value);
242 
244  void (SDLCALL *SetAttributeSource)(GPU_Renderer* renderer, int num_values, GPU_Attribute source);
245 
246 
247  // Shapes
248 
250  float (SDLCALL *SetLineThickness)(GPU_Renderer* renderer, float thickness);
251 
253  float (SDLCALL *GetLineThickness)(GPU_Renderer* renderer);
254 
256  void (SDLCALL *Pixel)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, SDL_Color color);
257 
259  void (SDLCALL *Line)(GPU_Renderer* renderer, GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);
260 
262  void (SDLCALL *Arc)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float radius, float start_angle, float end_angle, SDL_Color color);
263 
265  void (SDLCALL *ArcFilled)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float radius, float start_angle, float end_angle, SDL_Color color);
266 
268  void (SDLCALL *Circle)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float radius, SDL_Color color);
269 
271  void (SDLCALL *CircleFilled)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float radius, SDL_Color color);
272 
274  void (SDLCALL *Ellipse)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float rx, float ry, float degrees, SDL_Color color);
275 
277  void (SDLCALL *EllipseFilled)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float rx, float ry, float degrees, SDL_Color color);
278 
280  void (SDLCALL *Sector)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float inner_radius, float outer_radius, float start_angle, float end_angle, SDL_Color color);
281 
283  void (SDLCALL *SectorFilled)(GPU_Renderer* renderer, GPU_Target* target, float x, float y, float inner_radius, float outer_radius, float start_angle, float end_angle, SDL_Color color);
284 
286  void (SDLCALL *Tri)(GPU_Renderer* renderer, GPU_Target* target, float x1, float y1, float x2, float y2, float x3, float y3, SDL_Color color);
287 
289  void (SDLCALL *TriFilled)(GPU_Renderer* renderer, GPU_Target* target, float x1, float y1, float x2, float y2, float x3, float y3, SDL_Color color);
290 
292  void (SDLCALL *Rectangle)(GPU_Renderer* renderer, GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);
293 
295  void (SDLCALL *RectangleFilled)(GPU_Renderer* renderer, GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);
296 
298  void (SDLCALL *RectangleRound)(GPU_Renderer* renderer, GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color);
299 
301  void (SDLCALL *RectangleRoundFilled)(GPU_Renderer* renderer, GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color);
302 
304  void (SDLCALL *Polygon)(GPU_Renderer* renderer, GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color);
305 
307  void (SDLCALL *PolygonFilled)(GPU_Renderer* renderer, GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color);
308 
310 
311 #ifdef __cplusplus
312 }
313 #endif
314 
315 #endif
GPU_Image *SDLCALL * CopyImageFromSurface(GPU_Renderer *renderer, SDL_Surface *surface)
GPU_Target *SDLCALL * CreateTargetFromWindow(GPU_Renderer *renderer, Uint32 windowID, GPU_Target *target)
GPU_bool GPU_bool use_desktop_resolution
GPU_FilterEnum
Definition: SDL_gpu.h:193
float(SDLCALL *SetLineThickness)(GPU_Renderer *renderer
GPU_FileFormatEnum
Definition: SDL_gpu.h:247
GPU_WrapEnum
Definition: SDL_gpu.h:216
GPU_Image GPU_Rect GPU_Target float float float pivot_x
GPU_Image *SDLCALL * CreateImage(GPU_Renderer *renderer, Uint16 w, Uint16 h, GPU_FormatEnum format)
GPU_ShaderBlock(SDLCALL *LoadShaderBlock)(GPU_Renderer *renderer
GPU_Target Uint8 Uint8 Uint8 b
GPU_Image GPU_WrapEnum wrap_mode_x
GPU_Image GPU_Target unsigned short num_vertices
Uint32 const char * attrib_name
Uint32(SDLCALL *CreateShaderProgram)(GPU_Renderer *renderer)
const char *SDLCALL * GetShaderMessage(GPU_Renderer *renderer)
GPU_Image GPU_FilterEnum filter
GPU_Image GPU_WrapEnum GPU_WrapEnum wrap_mode_y
GPU_Image const GPU_Rect const unsigned char * bytes
GPU_Camera(SDLCALL *SetCamera)(GPU_Renderer *renderer
GPU_Image const char GPU_FileFormatEnum format
void(SDLCALL *MakeCurrent)(GPU_Renderer *renderer
GPU_Target float float float float float float y3
GPU_Image const GPU_Rect SDL_Surface * surface
Uint32 const char const char const char * color_name
GPU_Image GPU_Rect GPU_Target float x
int GPU_Attribute source
GPU_Image const GPU_Rect SDL_Surface const GPU_Rect * surface_rect
Uint32 GPU_BatchFlagEnum
Definition: SDL_gpu.h:485
GPU_ShaderEnum shader_type
GPU_Image GPU_Target unsigned short void unsigned int unsigned short * indices
DECLSPEC void SDLCALL GPU_AddWindowMapping(GPU_Target *target)
Definition: SDL_gpu.c:271
GPU_Target float float float float float x3
GPU_Target float float float float y2
GPU_Image GPU_Rect * src_rect
GPU_Target *SDLCALL * CreateAliasTarget(GPU_Renderer *renderer, GPU_Target *target)
GPU_ShaderEnum SDL_RWops * shader_source
GPU_Target unsigned int float * vertices
GPU_FormatEnum
Definition: SDL_gpu.h:226
GPU_Target *SDLCALL * Init(GPU_Renderer *renderer, GPU_RendererID renderer_request, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
GPU_Rect(SDLCALL *SetClip)(GPU_Renderer *renderer
GPU_Image GPU_Rect GPU_Target float float y
int int int int num_columns
Uint32 const char * position_name
GPU_Image GPU_Rect GPU_Target float float float float pivot_y
SDL_Surface *SDLCALL * CopySurfaceFromImage(GPU_Renderer *renderer, GPU_Image *image)
GPU_ShaderBlock block
Uint32 const char const char * texcoord_name
GPU_Image *SDLCALL * CopyImageFromTarget(GPU_Renderer *renderer, GPU_Target *target)
Uint32 GPU_WindowFlagEnum
Definition: SDL_gpu.h:458
GPU_Target *SDLCALL * GetTarget(GPU_Renderer *renderer, GPU_Image *image)
GPU_Image GPU_Target unsigned short void * values
GPU_Image *SDLCALL * CopyImage(GPU_Renderer *renderer, GPU_Image *image)
GPU_Target Uint32 windowID
Uint32 const char const char const char const char * modelViewMatrix_name
GPU_Image const GPU_Rect const unsigned char int bytes_per_row
GPU_Image GPU_Rect GPU_Target float float float float scaleY
int(SDLCALL *GetAttributeLocation)(GPU_Renderer *renderer
GPU_Target float float float radius
GPU_Target float float float float start_angle
GPU_Target Uint8 Uint8 g
GPU_Target float x1
GPU_Target float float float float ry
GPU_Target float float SDL_Color color
GPU_Target float float float rx
GPU_bool(SDLCALL *SetWindowResolution)(GPU_Renderer *renderer
GPU_ShaderEnum SDL_RWops GPU_bool free_rwops
SDL_Color(SDLCALL *GetPixel)(GPU_Renderer *renderer
DECLSPEC void SDLCALL GPU_RemoveWindowMappingByTarget(GPU_Target *target)
Definition: SDL_gpu.c:350
GPU_Target float float y1
GPU_Target float float float float float end_angle
GPU_Image *SDLCALL * CreateImageUsingTexture(GPU_Renderer *renderer, Uint32 handle, GPU_bool take_ownership)
GPU_Image *SDLCALL * CreateAliasImage(GPU_Renderer *renderer, GPU_Image *image)
GPU_Target float float float inner_radius
SDL_Surface *SDLCALL * CopySurfaceFromTarget(GPU_Renderer *renderer, GPU_Target *target)
int int int int GPU_bool transpose
Uint32 GPU_ShaderBlock * block
GPU_Target float float float float outer_radius
GPU_Target GPU_Camera * cam
GPU_Image GPU_Target unsigned short void unsigned int unsigned short GPU_BatchFlagEnum flags
GPU_Target Uint8 r
GPU_Image const GPU_Rect * image_rect
GPU_Image GPU_Target unsigned short void unsigned int num_indices
GPU_Image GPU_Rect GPU_Target float float float degrees
GPU_Image const char * filename
GPU_Image int int image_unit
GPU_Image GPU_Rect GPU_Target float float float scaleX
GPU_Target float float float x2
GPU_ShaderEnum
Definition: SDL_gpu.h:545
GPU_Target Uint8 Uint8 Uint8 Uint8 a
DECLSPEC void SDLCALL GPU_RemoveWindowMapping(Uint32 windowID)
Definition: SDL_gpu.c:319
Uint32 const char * uniform_name