| 1 |
/* |
| 2 |
|
| 3 |
Boost Software License - Version 1.0 - August 17th,2003 |
| 4 |
|
| 5 |
Permission is hereby granted,free of charge,to any person or organization |
| 6 |
obtaining a copy of the software and accompanying documentation covered by |
| 7 |
this license(the "Software") to use,reproduce,display,distribute, |
| 8 |
execute,and transmit the Software,and to prepare derivative works of the |
| 9 |
Software,and to permit third-parties to whom the Software is furnished to |
| 10 |
do so,all subject to the following: |
| 11 |
|
| 12 |
The copyright notices in the Software and this entire statement,including |
| 13 |
the above license grant,this restriction and the following disclaimer, |
| 14 |
must be included in all copies of the Software,in whole or in part,and |
| 15 |
all derivative works of the Software,unless such copies or derivative |
| 16 |
works are solely in the form of machine-executable object code generated by |
| 17 |
a source language processor. |
| 18 |
|
| 19 |
THE SOFTWARE IS PROVIDED "AS IS",WITHOUT WARRANTY OF ANY KIND,EXPRESS OR |
| 20 |
IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 |
FITNESS FOR A PARTICULAR PURPOSE,TITLE AND NON-INFRINGEMENT. IN NO EVENT |
| 22 |
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
| 23 |
FOR ANY DAMAGES OR OTHER LIABILITY,WHETHER IN CONTRACT,TORT OR OTHERWISE, |
| 24 |
ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 25 |
DEALINGS IN THE SOFTWARE. |
| 26 |
|
| 27 |
*/ |
| 28 |
module derelict.sdl2.internal.gpu_types; |
| 29 |
|
| 30 |
import core.stdc.stdarg : va_list; |
| 31 |
import derelict.sdl2.internal.sdl_types; |
| 32 |
|
| 33 |
version(DerelictSDL2GPU_UseIntBool) |
| 34 |
alias GPU_bool = int; |
| 35 |
else |
| 36 |
alias GPU_bool = bool; |
| 37 |
|
| 38 |
enum GPU_FALSE = 0; |
| 39 |
enum GPU_TRUE = 1; |
| 40 |
|
| 41 |
struct GPU_Rect { |
| 42 |
float x, y; |
| 43 |
float w, h; |
| 44 |
} |
| 45 |
|
| 46 |
alias GPU_RendererEnum = uint; |
| 47 |
enum : uint { |
| 48 |
GPU_RENDERER_UNKNOWN = 0, |
| 49 |
GPU_RENDERER_OPENGL_1_BASE = 1, |
| 50 |
GPU_RENDERER_OPENGL_1 = 2, |
| 51 |
GPU_RENDERER_OPENGL_2 = 3, |
| 52 |
GPU_RENDERER_OPENGL_3 = 4, |
| 53 |
GPU_RENDERER_OPENGL_4 = 5, |
| 54 |
GPU_RENDERER_GLES_1 = 11, |
| 55 |
GPU_RENDERER_GLES_2 = 12, |
| 56 |
GPU_RENDERER_GLES_3 = 13, |
| 57 |
GPU_RENDERER_D3D9 = 21, |
| 58 |
GPU_RENDERER_D3D10 = 22, |
| 59 |
GPU_RENDERER_D3D11 = 23, |
| 60 |
GPU_RENDERER_CUSTOM_0 = 1000, |
| 61 |
} |
| 62 |
|
| 63 |
struct GPU_RendererID { |
| 64 |
const(char)* name; |
| 65 |
GPU_RendererEnum renderer; |
| 66 |
int major_version; |
| 67 |
int minor_version; |
| 68 |
} |
| 69 |
|
| 70 |
alias GPU_BlendFuncEnum = int; |
| 71 |
enum { |
| 72 |
GPU_FUNC_ZERO = 0, |
| 73 |
GPU_FUNC_ONE = 1, |
| 74 |
GPU_FUNC_SRC_COLOR = 0x0300, |
| 75 |
GPU_FUNC_DST_COLOR = 0x0306, |
| 76 |
GPU_FUNC_ONE_MINUS_SRC = 0x0301, |
| 77 |
GPU_FUNC_ONE_MINUS_DST = 0x0307, |
| 78 |
GPU_FUNC_SRC_ALPHA = 0x0302, |
| 79 |
GPU_FUNC_DST_ALPHA = 0x0304, |
| 80 |
GPU_FUNC_ONE_MINUS_SRC_ALPHA = 0x0303, |
| 81 |
GPU_FUNC_ONE_MINUS_DST_ALPHA = 0x0305, |
| 82 |
} |
| 83 |
|
| 84 |
alias GPU_BlendEqEnum = int; |
| 85 |
enum { |
| 86 |
GPU_EQ_ADD = 0x8006, |
| 87 |
GPU_EQ_SUBTRACT = 0x800A, |
| 88 |
GPU_EQ_REVERSE_SUBRRACT = 0x800B, |
| 89 |
} |
| 90 |
|
| 91 |
struct GPU_BlendMode { |
| 92 |
GPU_BlendFuncEnum source_color; |
| 93 |
GPU_BlendFuncEnum dest_color; |
| 94 |
GPU_BlendFuncEnum source_alpha; |
| 95 |
GPU_BlendFuncEnum dest_alpha; |
| 96 |
GPU_BlendEqEnum color_equation; |
| 97 |
GPU_BlendEqEnum alpha_equation; |
| 98 |
} |
| 99 |
|
| 100 |
alias GPU_BlendPresetEnum = int; |
| 101 |
enum { |
| 102 |
GPU_BLEND_NORMAL = 0, |
| 103 |
GPU_BLEND_PREMULTIPLIED_ALPHA = 1, |
| 104 |
GPU_BLEND_MULTIPLY = 2, |
| 105 |
GPU_BLEND_ADD = 3, |
| 106 |
GPU_BLEND_SUBTRACT = 4, |
| 107 |
GPU_BLEND_MOD_ALPHA = 5, |
| 108 |
GPU_BLEND_SET_ALPHA = 6, |
| 109 |
GPU_BLEND_SET = 7, |
| 110 |
GPU_BLEND_NORMAL_KEEP_ALPHA = 8, |
| 111 |
GPU_BLEND_NORMAL_ADD_ALPHA = 9, |
| 112 |
GPU_BLEND_NORMAL_FACTOR_ALPHA = 10, |
| 113 |
} |
| 114 |
|
| 115 |
alias GPU_FilterEnum = int; |
| 116 |
enum { |
| 117 |
GPU_FILTER_NEAREST = 0, |
| 118 |
GPU_FILTER_LINEAR = 1, |
| 119 |
GPU_FILTER_LINEAR_MIPMAP = 2, |
| 120 |
} |
| 121 |
|
| 122 |
alias GPU_SnapEnum = int; |
| 123 |
enum { |
| 124 |
GPU_SNAP_NONE = 0, |
| 125 |
GPU_SNAP_POSITION = 1, |
| 126 |
GPU_SNAP_DIMENSIONS = 2, |
| 127 |
GPU_SNAP_POSITION_AND_DIMENSIONS = 3 |
| 128 |
} |
| 129 |
|
| 130 |
alias GPU_WrapEnum = int; |
| 131 |
enum { |
| 132 |
GPU_WRAP_NONE = 0, |
| 133 |
GPU_WRAP_REPEAT = 1, |
| 134 |
GPU_WRAP_MIRRORED = 2 |
| 135 |
} |
| 136 |
|
| 137 |
alias GPU_FormatEnum = int; |
| 138 |
enum { |
| 139 |
GPU_FORMAT_LUMINANCE = 1, |
| 140 |
GPU_FORMAT_LUMINANCE_ALPHA = 2, |
| 141 |
GPU_FORMAT_RGB = 3, |
| 142 |
GPU_FORMAT_RGBA = 4, |
| 143 |
GPU_FORMAT_ALPHA = 5, |
| 144 |
GPU_FORMAT_RG = 6, |
| 145 |
GPU_FORMAT_YCbCr422 = 7, |
| 146 |
GPU_FORMAT_YCbCr420P = 8, |
| 147 |
} |
| 148 |
|
| 149 |
alias GPU_FileFormatEnum = int; |
| 150 |
enum { |
| 151 |
GPU_FILE_AUTO = 0, |
| 152 |
GPU_FILE_PNG, |
| 153 |
GPU_FILE_BMP, |
| 154 |
GPU_FILE_TGA |
| 155 |
} |
| 156 |
|
| 157 |
struct GPU_Image { |
| 158 |
GPU_Renderer* renderer; |
| 159 |
GPU_Target* context_target; |
| 160 |
GPU_Target* target; |
| 161 |
ushort w, h; |
| 162 |
GPU_bool using_virtual_resolution; |
| 163 |
GPU_FormatEnum format; |
| 164 |
int num_layers; |
| 165 |
int bytes_per_pixel; |
| 166 |
ushort base_w, base_h; |
| 167 |
ushort texture_w, texture_h; |
| 168 |
GPU_bool has_mipmaps; |
| 169 |
float anchor_x; |
| 170 |
float anchor_y; |
| 171 |
SDL_Color color; |
| 172 |
GPU_bool use_blending; |
| 173 |
GPU_BlendMode blend_mode; |
| 174 |
GPU_FilterEnum filter_mode; |
| 175 |
GPU_SnapEnum snap_mode; |
| 176 |
GPU_WrapEnum wrap_mode_x; |
| 177 |
GPU_WrapEnum wrap_mode_y; |
| 178 |
void* data; |
| 179 |
int refcount; |
| 180 |
GPU_bool is_alias; |
| 181 |
} |
| 182 |
|
| 183 |
struct GPU_Camera { |
| 184 |
float x, y, z; |
| 185 |
float angle; |
| 186 |
float zoom; |
| 187 |
} |
| 188 |
|
| 189 |
struct GPU_ShaderBlock { |
| 190 |
int position_loc; |
| 191 |
int texcoord_loc; |
| 192 |
int color_loc; |
| 193 |
int modelViewProjection_loc; |
| 194 |
} |
| 195 |
|
| 196 |
enum GPU_MODELVIEW = 0; |
| 197 |
enum GPU_PROJECTION = 1; |
| 198 |
enum GPU_MATRIX_STACK_MAX = 5; |
| 199 |
|
| 200 |
struct GPU_MatrixStack { |
| 201 |
uint size; |
| 202 |
float[16][GPU_MATRIX_STACK_MAX] matrix; |
| 203 |
} |
| 204 |
|
| 205 |
struct GPU_Context { |
| 206 |
void* context; |
| 207 |
GPU_bool failed; |
| 208 |
uint windowID; |
| 209 |
int window_w; |
| 210 |
int window_h; |
| 211 |
int drawable_w; |
| 212 |
int drawable_h; |
| 213 |
int stored_window_w; |
| 214 |
int stored_window_h; |
| 215 |
uint current_shader_program; |
| 216 |
uint default_textured_shader_program; |
| 217 |
uint default_untextured_shader_program; |
| 218 |
GPU_ShaderBlock current_shader_block; |
| 219 |
GPU_ShaderBlock default_textured_shader_block; |
| 220 |
GPU_ShaderBlock default_untextured_shader_block; |
| 221 |
GPU_bool shapes_use_blending; |
| 222 |
GPU_BlendMode shapes_blend_mode; |
| 223 |
float line_thickness; |
| 224 |
GPU_bool use_texturing; |
| 225 |
int matrix_mode; |
| 226 |
GPU_MatrixStack projection_matrix; |
| 227 |
GPU_MatrixStack modelview_matrix; |
| 228 |
void* data; |
| 229 |
} |
| 230 |
|
| 231 |
struct GPU_Target { |
| 232 |
GPU_Renderer* renderer; |
| 233 |
GPU_Target* context_target; |
| 234 |
GPU_Image* image; |
| 235 |
void* data; |
| 236 |
ushort w, h; |
| 237 |
GPU_bool using_virtual_resolution; |
| 238 |
ushort base_w, base_h; |
| 239 |
GPU_bool use_clip_rect; |
| 240 |
GPU_Rect clip_rect; |
| 241 |
GPU_bool use_color; |
| 242 |
SDL_Color color; |
| 243 |
GPU_Rect viewport; |
| 244 |
GPU_Camera camera; |
| 245 |
GPU_bool use_camera; |
| 246 |
GPU_Context* context; |
| 247 |
int refcount; |
| 248 |
GPU_bool is_alias; |
| 249 |
} |
| 250 |
|
| 251 |
alias GPU_FeatureEnum = int; |
| 252 |
enum { |
| 253 |
GPU_FEATURE_NON_POWER_OF_TWO = 0x1, |
| 254 |
GPU_FEATURE_RENDER_TARGETS = 0x2, |
| 255 |
GPU_FEATURE_BLEND_EQUATIONS = 0x4, |
| 256 |
GPU_FEATURE_BLEND_FUNC_SEPARATE = 0x8, |
| 257 |
GPU_FEATURE_BLEND_EQUATIONS_SEPARATE = 0x10, |
| 258 |
GPU_FEATURE_GL_BGR = 0x20, |
| 259 |
GPU_FEATURE_GL_BGRA = 0x40, |
| 260 |
GPU_FEATURE_GL_ABGR = 0x80, |
| 261 |
GPU_FEATURE_VERTEX_SHADER = 0x100, |
| 262 |
GPU_FEATURE_FRAGMENT_SHADER = 0x200, |
| 263 |
GPU_FEATURE_PIXEL_SHADER = 0x200, |
| 264 |
GPU_FEATURE_GEOMETRY_SHADER = 0x400, |
| 265 |
GPU_FEATURE_WRAP_REPEAT_MIRRORED = 0x800, |
| 266 |
} |
| 267 |
|
| 268 |
alias GPU_WindowFlagEnum = uint; |
| 269 |
alias GPU_InitFlagEnum = uint; |
| 270 |
enum : uint { |
| 271 |
GPU_INIT_ENABLE_VSYNC = 0x1, |
| 272 |
GPU_INIT_DISABLE_VSYNC = 0x2, |
| 273 |
GPU_INIT_DISABLE_DOUBLE_BUFFER = 0x4, |
| 274 |
GPU_INIT_DISABLE_AUTO_VIRTUAL_RESOLUTION = 0x8, |
| 275 |
GPU_INIT_REQUEST_COMPATIBILITY_PROFILE = 0x10, |
| 276 |
} |
| 277 |
|
| 278 |
enum GPU_DEFAULT_INIT_FLAGS = 0; |
| 279 |
enum uint GPU_NONE = 0; |
| 280 |
|
| 281 |
alias GPU_BatchFlagEnum = uint; |
| 282 |
enum : uint { |
| 283 |
GPU_BATCH_XY = 0x1, |
| 284 |
GPU_BATCH_XYZ = 0x2, |
| 285 |
GPU_BATCH_ST = 0x4, |
| 286 |
GPU_BATCH_RGB = 0x8, |
| 287 |
GPU_BATCH_RGBA = 0x10, |
| 288 |
GPU_BATCH_RGB8 = 0x20, |
| 289 |
GPU_BATCH_RGBA8 = 0x40, |
| 290 |
GPU_BATCH_XY_ST = GPU_BATCH_XY | GPU_BATCH_ST, |
| 291 |
GPU_BATCH_XYZ_ST = GPU_BATCH_XYZ | GPU_BATCH_ST, |
| 292 |
GPU_BATCH_XY_RGB = GPU_BATCH_XY | GPU_BATCH_RGB, |
| 293 |
GPU_BATCH_XYZ_RGB = GPU_BATCH_XYZ | GPU_BATCH_RGB, |
| 294 |
GPU_BATCH_XY_RGBA = GPU_BATCH_XY | GPU_BATCH_RGBA, |
| 295 |
GPU_BATCH_XYZ_RGBA = GPU_BATCH_XYZ | GPU_BATCH_RGBA, |
| 296 |
GPU_BATCH_XY_ST_RGBA = GPU_BATCH_XY | GPU_BATCH_ST | GPU_BATCH_RGBA, |
| 297 |
GPU_BATCH_XYZ_ST_RGBA = GPU_BATCH_XYZ | GPU_BATCH_ST | GPU_BATCH_RGBA, |
| 298 |
GPU_BATCH_XY_RGB8 = GPU_BATCH_XY | GPU_BATCH_RGB8, |
| 299 |
GPU_BATCH_XYZ_RGB8 = GPU_BATCH_XYZ | GPU_BATCH_RGB8, |
| 300 |
GPU_BATCH_XY_RGBA8 = GPU_BATCH_XY | GPU_BATCH_RGBA8, |
| 301 |
GPU_BATCH_XYZ_RGBA8 = GPU_BATCH_XYZ | GPU_BATCH_RGBA8, |
| 302 |
GPU_BATCH_XY_ST_RGBA8 = GPU_BATCH_XY | GPU_BATCH_ST | GPU_BATCH_RGBA8, |
| 303 |
GPU_BATCH_XYZ_ST_RGBA8 = GPU_BATCH_XYZ | GPU_BATCH_ST | GPU_BATCH_RGBA8, |
| 304 |
} |
| 305 |
|
| 306 |
alias GPU_FlipEnum = uint; |
| 307 |
enum : uint { |
| 308 |
GPU_FLIP_NONE = 0x0, |
| 309 |
GPU_FLIP_HORIZONTAL = 0x1, |
| 310 |
GPU_FLIP_VERTICAL = 0x2, |
| 311 |
} |
| 312 |
|
| 313 |
alias GPU_TypeEnum = uint; |
| 314 |
enum : uint { |
| 315 |
GPU_TYPE_BYTE = 0x1400, |
| 316 |
GPU_TYPE_UNSIGNED_BYTE = 0x1401, |
| 317 |
GPU_TYPE_SHORT = 0x1402, |
| 318 |
GPU_TYPE_UNSIGNED_SHORT = 0x1403, |
| 319 |
GPU_TYPE_INT = 0x1404, |
| 320 |
GPU_TYPE_UNSIGNED_INT = 0x1405, |
| 321 |
GPU_TYPE_FLOAT = 0x1406, |
| 322 |
GPU_TYPE_DOUBLE = 0x140A, |
| 323 |
} |
| 324 |
|
| 325 |
alias GPU_ShaderEnum = int; |
| 326 |
enum { |
| 327 |
GPU_VERTEX_SHADER = 0, |
| 328 |
GPU_FRAGMENT_SHADER = 1, |
| 329 |
GPU_PIXEL_SHADER = 1, |
| 330 |
GPU_GEOMETRY_SHADER = 2, |
| 331 |
} |
| 332 |
|
| 333 |
alias GPU_ShaderLanguageEnum = int; |
| 334 |
enum { |
| 335 |
GPU_LANGUAGE_NONE = 0, |
| 336 |
GPU_LANGUAGE_ARB_ASSEMBLY = 1, |
| 337 |
GPU_LANGUAGE_GLSL = 2, |
| 338 |
GPU_LANGUAGE_GLSLES = 3, |
| 339 |
GPU_LANGUAGE_HLSL = 4, |
| 340 |
GPU_LANGUAGE_CG = 5, |
| 341 |
} |
| 342 |
|
| 343 |
struct GPU_AttributeFormat { |
| 344 |
GPU_bool is_per_sprite; |
| 345 |
int num_elems_per_value; |
| 346 |
GPU_TypeEnum type; |
| 347 |
GPU_bool normalize; |
| 348 |
int stride_bytes; |
| 349 |
int offset_bytes; |
| 350 |
} |
| 351 |
|
| 352 |
struct GPU_Attribute { |
| 353 |
int location; |
| 354 |
void* values; |
| 355 |
GPU_AttributeFormat format; |
| 356 |
} |
| 357 |
|
| 358 |
struct GPU_AttributeSource { |
| 359 |
GPU_bool enabled; |
| 360 |
int num_values; |
| 361 |
void* next_value; |
| 362 |
int per_vertex_storage_stride_bytes; |
| 363 |
int per_vertex_storage_offset_bytes; |
| 364 |
int per_vertex_storage_size; |
| 365 |
void* per_vertex_storage; |
| 366 |
GPU_Attribute attribute; |
| 367 |
} |
| 368 |
|
| 369 |
alias GPU_ErrorEnum = int; |
| 370 |
enum { |
| 371 |
GPU_ERROR_NONE = 0, |
| 372 |
GPU_ERROR_BACKEND_ERROR = 1, |
| 373 |
GPU_ERROR_DATA_ERROR = 2, |
| 374 |
GPU_ERROR_USER_ERROR = 3, |
| 375 |
GPU_ERROR_UNSUPPORTED_FUNCTION = 4, |
| 376 |
GPU_ERROR_NULL_ARGUMENT = 5, |
| 377 |
GPU_ERROR_FILE_NOT_FOUND = 6, |
| 378 |
} |
| 379 |
|
| 380 |
struct GPU_ErrorObject { |
| 381 |
char* function_; |
| 382 |
GPU_ErrorEnum error; |
| 383 |
char* details; |
| 384 |
} |
| 385 |
|
| 386 |
alias GPU_DebugLevelEnum = int; |
| 387 |
enum { |
| 388 |
GPU_DEBUG_LEVEL_0 = 0, |
| 389 |
GPU_DEBUG_LEVEL_1 = 1, |
| 390 |
GPU_DEBUG_LEVEL_2 = 2, |
| 391 |
GPU_DEBUG_LEVEL_3 = 3, |
| 392 |
GPU_DEBUG_LEVEL_MAX = 3, |
| 393 |
} |
| 394 |
|
| 395 |
alias GPU_LogLevelEnum = int; |
| 396 |
enum { |
| 397 |
GPU_LOG_INFO = 0, |
| 398 |
GPU_LOG_WARNING, |
| 399 |
GPU_LOG_ERROR, |
| 400 |
} |
| 401 |
|
| 402 |
struct GPU_RendererImpl; |
| 403 |
struct GPU_Renderer { |
| 404 |
GPU_RendererID id; |
| 405 |
GPU_RendererID requested_id; |
| 406 |
GPU_WindowFlagEnum SDL_init_flags; |
| 407 |
GPU_InitFlagEnum GPU_init_flags; |
| 408 |
GPU_ShaderLanguageEnum shader_language; |
| 409 |
int min_shader_version; |
| 410 |
int max_shader_version; |
| 411 |
GPU_FeatureEnum enabled_features; |
| 412 |
GPU_Target* current_context_target; |
| 413 |
GPU_bool coordinate_mode; |
| 414 |
float default_image_anchor_x; |
| 415 |
float default_image_anchor_y; |
| 416 |
GPU_RendererImpl* impl; |
| 417 |
} |
| 418 |
|
| 419 |
extern(C) nothrow { |
| 420 |
alias LogCallback = int function(GPU_LogLevelEnum,const(char)*,va_list); |
| 421 |
alias RendererConstructor = GPU_Renderer* function(GPU_RendererID); |
| 422 |
alias RendererDestructor = void function(GPU_Renderer*); |
| 423 |
} |