[395] | 1 | // Copyright (C) 2012-2015 ChaosForge Ltd
|
---|
| 2 | // http://chaosforge.org/
|
---|
| 3 | //
|
---|
| 4 | // This file is part of Nova libraries.
|
---|
| 5 | // For conditions of distribution and use, see copying.txt file in root folder.
|
---|
[35] | 6 |
|
---|
| 7 | #include "nv/gl/gl_enum.hh"
|
---|
| 8 |
|
---|
| 9 | #include "nv/lib/gl.hh"
|
---|
| 10 |
|
---|
| 11 | using namespace nv;
|
---|
| 12 |
|
---|
[331] | 13 | unsigned int nv::texture_type_to_enum( texture_type type )
|
---|
| 14 | {
|
---|
| 15 | switch( type )
|
---|
| 16 | {
|
---|
[491] | 17 | case TEXTURE_1D : return GL_TEXTURE_1D;
|
---|
| 18 | case TEXTURE_2D : return GL_TEXTURE_2D;
|
---|
| 19 | case TEXTURE_RECT : return GL_TEXTURE_RECTANGLE;
|
---|
| 20 | case TEXTURE_3D : return GL_TEXTURE_3D;
|
---|
| 21 | case TEXTURE_CUBE : return GL_TEXTURE_CUBE_MAP;
|
---|
| 22 | case TEXTURE_1D_ARRAY : return GL_TEXTURE_1D_ARRAY;
|
---|
| 23 | case TEXTURE_2D_ARRAY : return GL_TEXTURE_2D_ARRAY;
|
---|
| 24 | case TEXTURE_1D_BUFFER: return GL_TEXTURE_BUFFER;
|
---|
[331] | 25 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
| 26 | }
|
---|
| 27 | }
|
---|
| 28 |
|
---|
[40] | 29 | unsigned int nv::clear_state_buffers_to_mask( clear_state::buffers_type type )
|
---|
[35] | 30 | {
|
---|
| 31 | unsigned int mask = 0;
|
---|
| 32 | if ( (type & clear_state::COLOR_BUFFER) != 0 ) mask |= GL_COLOR_BUFFER_BIT;
|
---|
| 33 | if ( (type & clear_state::DEPTH_BUFFER) != 0 ) mask |= GL_DEPTH_BUFFER_BIT;
|
---|
| 34 | if ( (type & clear_state::STENCIL_BUFFER) != 0 ) mask |= GL_STENCIL_BUFFER_BIT;
|
---|
| 35 | return mask;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
[40] | 38 | unsigned int nv::depth_state_function_to_enum( depth_test::function_type type )
|
---|
[35] | 39 | {
|
---|
| 40 | switch( type )
|
---|
| 41 | {
|
---|
| 42 | case depth_test::NEVER : return GL_NEVER;
|
---|
| 43 | case depth_test::LESS : return GL_LESS;
|
---|
| 44 | case depth_test::EQUAL : return GL_EQUAL;
|
---|
| 45 | case depth_test::LESS_OR_EQUAL : return GL_LEQUAL;
|
---|
| 46 | case depth_test::GREATER : return GL_GREATER;
|
---|
| 47 | case depth_test::NOT_EQUAL : return GL_NOTEQUAL;
|
---|
| 48 | case depth_test::GREATER_OR_EQUAL : return GL_GEQUAL;
|
---|
| 49 | case depth_test::ALWAYS : return GL_ALWAYS;
|
---|
[121] | 50 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[35] | 51 | }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
[233] | 54 | unsigned int nv::polygon_mode_fill_to_enum( polygon_mode::fill_type type )
|
---|
| 55 | {
|
---|
| 56 | switch( type )
|
---|
| 57 | {
|
---|
| 58 | case polygon_mode::FILL : return GL_FILL;
|
---|
| 59 | case polygon_mode::LINE : return GL_LINE;
|
---|
| 60 | case polygon_mode::POINT : return GL_POINT;
|
---|
| 61 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 |
|
---|
[40] | 67 | unsigned int nv::blending_factor_to_enum( blending::factor type )
|
---|
[35] | 68 | {
|
---|
| 69 | switch( type )
|
---|
| 70 | {
|
---|
| 71 | case blending::ZERO : return GL_ZERO;
|
---|
| 72 | case blending::ONE : return GL_ONE;
|
---|
| 73 | case blending::SRC_COLOR : return GL_SRC_COLOR;
|
---|
| 74 | case blending::ONE_MINUS_SRC_COLOR : return GL_ONE_MINUS_SRC_COLOR;
|
---|
| 75 | case blending::DST_COLOR : return GL_DST_COLOR;
|
---|
| 76 | case blending::ONE_MINUS_DST_COLOR : return GL_ONE_MINUS_DST_COLOR;
|
---|
| 77 | case blending::SRC_ALPHA : return GL_SRC_ALPHA;
|
---|
| 78 | case blending::ONE_MINUS_SRC_ALPHA : return GL_ONE_MINUS_SRC_ALPHA;
|
---|
| 79 | case blending::DST_ALPHA : return GL_DST_ALPHA;
|
---|
| 80 | case blending::ONE_MINUS_DST_ALPHA : return GL_ONE_MINUS_DST_ALPHA;
|
---|
| 81 | case blending::CONSTANT_COLOR : return GL_CONSTANT_COLOR;
|
---|
| 82 | case blending::ONE_MINUS_CONSTANT_COLOR: return GL_ONE_MINUS_CONSTANT_COLOR;
|
---|
| 83 | case blending::CONSTANT_ALPHA : return GL_CONSTANT_ALPHA;
|
---|
| 84 | case blending::ONE_MINUS_CONSTANT_ALPHA: return GL_ONE_MINUS_CONSTANT_ALPHA;
|
---|
| 85 | case blending::SRC_ALPHA_SATURATE : return GL_SRC_ALPHA_SATURATE;
|
---|
[121] | 86 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[35] | 87 | }
|
---|
| 88 | }
|
---|
| 89 |
|
---|
[40] | 90 | unsigned int nv::blending_equation_to_enum( blending::equation type )
|
---|
[35] | 91 | {
|
---|
| 92 | switch( type )
|
---|
| 93 | {
|
---|
| 94 | case blending::ADD : return GL_FUNC_ADD;
|
---|
| 95 | case blending::SUBTRACT : return GL_FUNC_SUBTRACT;
|
---|
| 96 | case blending::REVERSE_SUBTRACT : return GL_FUNC_REVERSE_SUBTRACT;
|
---|
| 97 | case blending::MINIMUM : return GL_MIN;
|
---|
| 98 | case blending::MAXIMUM : return GL_MAX;
|
---|
[121] | 99 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[35] | 100 | }
|
---|
| 101 | }
|
---|
| 102 |
|
---|
[40] | 103 | unsigned int nv::culling_face_type_to_enum( culling::face_type type )
|
---|
[35] | 104 | {
|
---|
| 105 | switch( type )
|
---|
| 106 | {
|
---|
| 107 | case culling::FRONT : return GL_FRONT;
|
---|
| 108 | case culling::BACK : return GL_BACK;
|
---|
| 109 | case culling::FRONT_AND_BACK : return GL_FRONT_AND_BACK;
|
---|
[121] | 110 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[35] | 111 | }
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[40] | 114 | unsigned int nv::culling_order_type_to_enum( culling::order_type type )
|
---|
[35] | 115 | {
|
---|
| 116 | switch( type )
|
---|
| 117 | {
|
---|
| 118 | case culling::CW : return GL_CW;
|
---|
| 119 | case culling::CCW : return GL_CCW;
|
---|
[121] | 120 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[35] | 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
[40] | 124 | unsigned int nv::stencil_function_to_enum( stencil_test_face::function_type type )
|
---|
[35] | 125 | {
|
---|
| 126 | switch( type )
|
---|
| 127 | {
|
---|
| 128 | case stencil_test_face::NEVER : return GL_NEVER;
|
---|
| 129 | case stencil_test_face::LESS : return GL_LESS;
|
---|
| 130 | case stencil_test_face::EQUAL : return GL_EQUAL;
|
---|
| 131 | case stencil_test_face::LESS_OR_EQUAL : return GL_LEQUAL;
|
---|
| 132 | case stencil_test_face::GREATER : return GL_GREATER;
|
---|
| 133 | case stencil_test_face::NOT_EQUAL : return GL_NOTEQUAL;
|
---|
| 134 | case stencil_test_face::GREATER_OR_EQUAL : return GL_GEQUAL;
|
---|
| 135 | case stencil_test_face::ALWAYS : return GL_ALWAYS;
|
---|
[121] | 136 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[35] | 137 | }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
[40] | 140 | unsigned int nv::stencil_operation_to_enum( stencil_test_face::operation type )
|
---|
[35] | 141 | {
|
---|
| 142 | switch( type )
|
---|
| 143 | {
|
---|
| 144 | case stencil_test_face::ZERO : return GL_ZERO;
|
---|
| 145 | case stencil_test_face::INVERT : return GL_INVERT;
|
---|
| 146 | case stencil_test_face::KEEP : return GL_KEEP;
|
---|
| 147 | case stencil_test_face::REPLACE : return GL_REPLACE;
|
---|
| 148 | case stencil_test_face::INCREMENT : return GL_INCR;
|
---|
| 149 | case stencil_test_face::DECREMENT : return GL_DECR;
|
---|
| 150 | case stencil_test_face::INCREMENT_WRAP : return GL_INCR_WRAP;
|
---|
| 151 | case stencil_test_face::DECREMENT_WRAP : return GL_DECR_WRAP;
|
---|
[121] | 152 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[35] | 153 | }
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[42] | 156 | unsigned int nv::buffer_hint_to_enum( buffer_hint hint )
|
---|
| 157 | {
|
---|
| 158 | switch( hint )
|
---|
| 159 | {
|
---|
| 160 | case STATIC_DRAW : return GL_STATIC_DRAW;
|
---|
| 161 | case STREAM_DRAW : return GL_STREAM_DRAW;
|
---|
| 162 | case DYNAMIC_DRAW : return GL_DYNAMIC_DRAW;
|
---|
[121] | 163 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[42] | 164 | }
|
---|
| 165 | }
|
---|
| 166 |
|
---|
[302] | 167 | unsigned int nv::buffer_type_to_enum( buffer_type type )
|
---|
| 168 | {
|
---|
| 169 | switch( type )
|
---|
| 170 | {
|
---|
[473] | 171 | case VERTEX_BUFFER : return GL_ARRAY_BUFFER;
|
---|
| 172 | case INDEX_BUFFER : return GL_ELEMENT_ARRAY_BUFFER;
|
---|
| 173 | case UNIFORM_BUFFER : return GL_UNIFORM_BUFFER;
|
---|
[491] | 174 | case TEXTURE_BUFFER : return GL_TEXTURE_BUFFER;
|
---|
[302] | 175 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 |
|
---|
[292] | 179 | unsigned int nv::image_format_to_enum( pixel_format format )
|
---|
[43] | 180 | {
|
---|
| 181 | switch( format )
|
---|
| 182 | {
|
---|
[340] | 183 | case RGB : return GL_RGB;
|
---|
| 184 | case RGBA : return GL_RGBA;
|
---|
| 185 | case RGB32F : return GL_RGB;
|
---|
| 186 | case RGBA32F : return GL_RGBA;
|
---|
| 187 | case RGB16F : return GL_RGB;
|
---|
| 188 | case RGBA16F : return GL_RGBA;
|
---|
[351] | 189 | case BGR : return GL_BGR;
|
---|
| 190 | case BGRA : return GL_BGRA;
|
---|
[461] | 191 | case RED : return GL_RED;
|
---|
[472] | 192 | case R16F : return GL_RED;
|
---|
| 193 | case R32F : return GL_RED;
|
---|
[462] | 194 | case DEPTH16 : return GL_DEPTH_COMPONENT;
|
---|
| 195 | case DEPTH24 : return GL_DEPTH_COMPONENT;
|
---|
| 196 | case DEPTH32 : return GL_DEPTH_COMPONENT;
|
---|
[491] | 197 | case R8I : return GL_RED_INTEGER;
|
---|
| 198 | case R8UI : return GL_RED_INTEGER;
|
---|
| 199 | case R16I : return GL_RED_INTEGER;
|
---|
| 200 | case R16UI : return GL_RED_INTEGER;
|
---|
| 201 | case R32I : return GL_RED_INTEGER;
|
---|
| 202 | case R32UI : return GL_RED_INTEGER;
|
---|
[121] | 203 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[43] | 204 | }
|
---|
| 205 | }
|
---|
| 206 |
|
---|
[331] | 207 | unsigned int nv::image_format_to_internal_enum( pixel_format format )
|
---|
| 208 | {
|
---|
| 209 | switch( format )
|
---|
| 210 | {
|
---|
[340] | 211 | case RGB : return GL_RGB8;
|
---|
| 212 | case RGBA : return GL_RGBA8;
|
---|
| 213 | case RGB32F : return GL_RGB32F;
|
---|
| 214 | case RGBA32F : return GL_RGBA32F;
|
---|
| 215 | case RGB16F : return GL_RGBA16F;
|
---|
| 216 | case RGBA16F : return GL_RGBA16F;
|
---|
[351] | 217 | case BGR : return GL_RGB8;
|
---|
| 218 | case BGRA : return GL_RGBA8;
|
---|
[472] | 219 | case RED : return GL_R8;
|
---|
| 220 | case R16F : return GL_R16F;
|
---|
| 221 | case R32F : return GL_R32F;
|
---|
[462] | 222 | case DEPTH16 : return GL_DEPTH_COMPONENT16;
|
---|
| 223 | case DEPTH24 : return GL_DEPTH_COMPONENT24;
|
---|
| 224 | case DEPTH32: return GL_DEPTH_COMPONENT32;
|
---|
[491] | 225 | case R8I : return GL_R8I;
|
---|
| 226 | case R8UI : return GL_R8UI;
|
---|
| 227 | case R16I : return GL_R16I;
|
---|
| 228 | case R16UI : return GL_R16UI;
|
---|
| 229 | case R32I : return GL_R32I;
|
---|
| 230 | case R32UI : return GL_R32UI;
|
---|
[340] | 231 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[331] | 232 | }
|
---|
| 233 | }
|
---|
| 234 |
|
---|
| 235 |
|
---|
[49] | 236 | unsigned int nv::sampler_filter_to_enum( sampler::filter filter )
|
---|
[43] | 237 | {
|
---|
| 238 | switch( filter )
|
---|
| 239 | {
|
---|
[49] | 240 | case sampler::LINEAR : return GL_LINEAR;
|
---|
| 241 | case sampler::NEAREST : return GL_NEAREST;
|
---|
| 242 | case sampler::NEAREST_MIPMAP_NEAREST : return GL_NEAREST_MIPMAP_NEAREST;
|
---|
| 243 | case sampler::LINEAR_MIPMAP_NEAREST : return GL_LINEAR_MIPMAP_NEAREST;
|
---|
| 244 | case sampler::NEAREST_MIPMAP_LINEAR : return GL_NEAREST_MIPMAP_LINEAR;
|
---|
| 245 | case sampler::LINEAR_MIPMAP_LINEAR : return GL_LINEAR_MIPMAP_LINEAR;
|
---|
[121] | 246 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[43] | 247 | }
|
---|
| 248 | }
|
---|
| 249 |
|
---|
[49] | 250 | unsigned int nv::sampler_wrap_to_enum( sampler::wrap wrap )
|
---|
[43] | 251 | {
|
---|
| 252 | switch( wrap )
|
---|
| 253 | {
|
---|
[49] | 254 | case sampler::CLAMP_TO_EDGE : return GL_CLAMP_TO_EDGE;
|
---|
| 255 | case sampler::CLAMP_TO_BORDER : return GL_CLAMP_TO_BORDER;
|
---|
| 256 | case sampler::MIRRORED_REPEAT : return GL_MIRRORED_REPEAT;
|
---|
| 257 | case sampler::REPEAT : return GL_REPEAT;
|
---|
[121] | 258 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[43] | 259 | }
|
---|
| 260 | }
|
---|
| 261 |
|
---|
[45] | 262 | unsigned int nv::primitive_to_enum( primitive p )
|
---|
| 263 | {
|
---|
| 264 | switch( p )
|
---|
| 265 | {
|
---|
| 266 | case POINTS : return GL_POINTS;
|
---|
| 267 | case LINES : return GL_LINES;
|
---|
| 268 | case LINE_LOOP : return GL_LINE_LOOP;
|
---|
| 269 | case LINE_STRIP : return GL_LINE_STRIP;
|
---|
| 270 | case TRIANGLES : return GL_TRIANGLES;
|
---|
| 271 | case TRIANGLE_STRIP : return GL_TRIANGLE_STRIP;
|
---|
| 272 | case TRIANGLE_FAN : return GL_TRIANGLE_FAN;
|
---|
[121] | 273 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
[45] | 274 | }
|
---|
| 275 | }
|
---|
[43] | 276 |
|
---|
[331] | 277 | unsigned int nv::framebuffer_slot_to_enum( framebuffer_slot slot )
|
---|
| 278 | {
|
---|
| 279 | switch( slot )
|
---|
| 280 | {
|
---|
| 281 | case READ_FRAMEBUFFER : return GL_READ_FRAMEBUFFER;
|
---|
| 282 | case DRAW_FRAMEBUFFER : return GL_DRAW_FRAMEBUFFER;
|
---|
| 283 | case FRAMEBUFFER : return GL_FRAMEBUFFER;
|
---|
| 284 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
| 285 | }
|
---|
| 286 | }
|
---|
| 287 |
|
---|
| 288 |
|
---|
| 289 | unsigned int nv::output_slot_to_enum( output_slot slot )
|
---|
| 290 | {
|
---|
| 291 | switch( slot )
|
---|
| 292 | {
|
---|
| 293 | case OUTPUT_0 : return GL_COLOR_ATTACHMENT0;
|
---|
| 294 | case OUTPUT_1 : return GL_COLOR_ATTACHMENT1;
|
---|
| 295 | case OUTPUT_2 : return GL_COLOR_ATTACHMENT2;
|
---|
| 296 | case OUTPUT_3 : return GL_COLOR_ATTACHMENT3;
|
---|
| 297 | case OUTPUT_4 : return GL_COLOR_ATTACHMENT4;
|
---|
| 298 | case OUTPUT_5 : return GL_COLOR_ATTACHMENT5;
|
---|
| 299 | case OUTPUT_6 : return GL_COLOR_ATTACHMENT6;
|
---|
| 300 | case OUTPUT_7 : return GL_COLOR_ATTACHMENT7;
|
---|
| 301 | case OUTPUT_NONE : return 0;
|
---|
| 302 | case OUTPUT_FRONT : return GL_FRONT;
|
---|
| 303 | case OUTPUT_BACK : return GL_BACK;
|
---|
| 304 | NV_RETURN_COVERED_DEFAULT( 0 );
|
---|
| 305 | }
|
---|
| 306 | }
|
---|
| 307 |
|
---|
| 308 |
|
---|
[70] | 309 | unsigned int nv::datatype_to_gl_enum( datatype type )
|
---|
[35] | 310 | {
|
---|
| 311 | switch( type )
|
---|
| 312 | {
|
---|
[44] | 313 | case BYTE : return GL_BYTE;
|
---|
| 314 | case UBYTE : return GL_UNSIGNED_BYTE;
|
---|
| 315 | case SHORT : return GL_SHORT;
|
---|
| 316 | case USHORT : return GL_UNSIGNED_SHORT;
|
---|
| 317 | case INT : return GL_INT;
|
---|
| 318 | case UINT : return GL_UNSIGNED_INT;
|
---|
[35] | 319 | case FLOAT : return GL_FLOAT;
|
---|
| 320 | case FLOAT_VECTOR_2 : return GL_FLOAT_VEC2;
|
---|
| 321 | case FLOAT_VECTOR_3 : return GL_FLOAT_VEC3;
|
---|
| 322 | case FLOAT_VECTOR_4 : return GL_FLOAT_VEC4;
|
---|
| 323 | case FLOAT_MATRIX_2 : return GL_FLOAT_MAT2;
|
---|
| 324 | case FLOAT_MATRIX_3 : return GL_FLOAT_MAT3;
|
---|
| 325 | case FLOAT_MATRIX_4 : return GL_FLOAT_MAT4;
|
---|
| 326 | case INT_VECTOR_2 : return GL_INT_VEC2;
|
---|
| 327 | case INT_VECTOR_3 : return GL_INT_VEC3;
|
---|
| 328 | case INT_VECTOR_4 : return GL_INT_VEC4;
|
---|
[68] | 329 | // remove, error or ?
|
---|
| 330 | case BYTE_VECTOR_2 : return GL_INT_VEC2;
|
---|
| 331 | case BYTE_VECTOR_3 : return GL_INT_VEC3;
|
---|
| 332 | case BYTE_VECTOR_4 : return GL_INT_VEC4;
|
---|
[350] | 333 | // remove, error or ?
|
---|
| 334 | case UBYTE_VECTOR_2: return GL_INT_VEC2;
|
---|
| 335 | case UBYTE_VECTOR_3: return GL_INT_VEC3;
|
---|
| 336 | case UBYTE_VECTOR_4: return GL_INT_VEC4;
|
---|
| 337 | default: return 0; // TODO: throw!
|
---|
[35] | 338 | }
|
---|
| 339 | }
|
---|
| 340 |
|
---|
[70] | 341 | nv::datatype nv::gl_enum_to_datatype( unsigned int gl_enum )
|
---|
[35] | 342 | {
|
---|
| 343 | switch( gl_enum )
|
---|
| 344 | {
|
---|
[44] | 345 | case GL_BYTE : return BYTE;
|
---|
| 346 | case GL_UNSIGNED_BYTE : return UBYTE;
|
---|
| 347 | case GL_SHORT : return SHORT;
|
---|
| 348 | case GL_UNSIGNED_SHORT : return USHORT;
|
---|
| 349 | case GL_INT : return INT;
|
---|
| 350 | case GL_UNSIGNED_INT : return UINT;
|
---|
| 351 | case GL_FLOAT : return FLOAT;
|
---|
| 352 | case GL_FLOAT_VEC2 : return FLOAT_VECTOR_2;
|
---|
| 353 | case GL_FLOAT_VEC3 : return FLOAT_VECTOR_3;
|
---|
| 354 | case GL_FLOAT_VEC4 : return FLOAT_VECTOR_4;
|
---|
| 355 | case GL_FLOAT_MAT2 : return FLOAT_MATRIX_2;
|
---|
| 356 | case GL_FLOAT_MAT3 : return FLOAT_MATRIX_3;
|
---|
| 357 | case GL_FLOAT_MAT4 : return FLOAT_MATRIX_4;
|
---|
| 358 | case GL_INT_VEC2 : return INT_VECTOR_2;
|
---|
| 359 | case GL_INT_VEC3 : return INT_VECTOR_3;
|
---|
| 360 | case GL_INT_VEC4 : return INT_VECTOR_4;
|
---|
[237] | 361 | // TODO: separate types?
|
---|
[331] | 362 | case GL_SAMPLER_1D : return INT;
|
---|
| 363 | case GL_SAMPLER_2D : return INT;
|
---|
| 364 | case GL_SAMPLER_3D : return INT;
|
---|
| 365 | case GL_SAMPLER_2D_RECT : return INT;
|
---|
| 366 | case GL_SAMPLER_2D_RECT_SHADOW : return INT;
|
---|
| 367 | case GL_SAMPLER_CUBE : return INT;
|
---|
| 368 | case GL_SAMPLER_1D_SHADOW : return INT;
|
---|
| 369 | case GL_SAMPLER_2D_SHADOW : return INT;
|
---|
[463] | 370 | case GL_SAMPLER_1D_ARRAY : return INT;
|
---|
| 371 | case GL_SAMPLER_2D_ARRAY : return INT;
|
---|
| 372 | case GL_SAMPLER_1D_ARRAY_SHADOW: return INT;
|
---|
| 373 | case GL_SAMPLER_2D_ARRAY_SHADOW: return INT;
|
---|
[491] | 374 | case GL_SAMPLER_BUFFER : return INT;
|
---|
| 375 |
|
---|
| 376 | case GL_INT_SAMPLER_1D : return INT;
|
---|
| 377 | case GL_INT_SAMPLER_2D : return INT;
|
---|
| 378 | case GL_INT_SAMPLER_3D : return INT;
|
---|
| 379 | case GL_INT_SAMPLER_2D_RECT : return INT;
|
---|
| 380 | case GL_INT_SAMPLER_CUBE : return INT;
|
---|
| 381 | case GL_INT_SAMPLER_1D_ARRAY : return INT;
|
---|
| 382 | case GL_INT_SAMPLER_2D_ARRAY : return INT;
|
---|
| 383 | case GL_INT_SAMPLER_BUFFER : return INT;
|
---|
| 384 | case GL_UNSIGNED_INT_SAMPLER_1D : return INT;
|
---|
| 385 | case GL_UNSIGNED_INT_SAMPLER_2D : return INT;
|
---|
| 386 | case GL_UNSIGNED_INT_SAMPLER_3D : return INT;
|
---|
| 387 | case GL_UNSIGNED_INT_SAMPLER_2D_RECT : return INT;
|
---|
| 388 | case GL_UNSIGNED_INT_SAMPLER_CUBE : return INT;
|
---|
| 389 | case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY : return INT;
|
---|
| 390 | case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY : return INT;
|
---|
| 391 | case GL_UNSIGNED_INT_SAMPLER_BUFFER : return INT;
|
---|
[463] | 392 | // TODO: implement?
|
---|
[237] | 393 | // case GL_BOOL
|
---|
| 394 | // case GL_BOOL_VEC2
|
---|
| 395 | // case GL_BOOL_VEC3
|
---|
| 396 | // case GL_BOOL_VEC4
|
---|
| 397 | // case GL_FLOAT_MAT2x3
|
---|
| 398 | // case GL_FLOAT_MAT2x4
|
---|
| 399 | // case GL_FLOAT_MAT3x2
|
---|
| 400 | // case GL_FLOAT_MAT3x4
|
---|
| 401 | // case GL_FLOAT_MAT4x2
|
---|
| 402 | // case GL_FLOAT_MAT4x3
|
---|
[70] | 403 | default : return datatype(0); // TODO: throw!
|
---|
[35] | 404 | }
|
---|
| 405 | }
|
---|
[316] | 406 |
|
---|
[438] | 407 | string_view nv::datatype_to_glsl_type( datatype type )
|
---|
[316] | 408 | {
|
---|
| 409 | switch( type )
|
---|
| 410 | {
|
---|
| 411 | case INT : return "int";
|
---|
| 412 | case FLOAT : return "float";
|
---|
| 413 | case FLOAT_VECTOR_2 : return "vec2";
|
---|
| 414 | case FLOAT_VECTOR_3 : return "vec3";
|
---|
| 415 | case FLOAT_VECTOR_4 : return "vec4";
|
---|
| 416 | case FLOAT_MATRIX_2 : return "mat2";
|
---|
| 417 | case FLOAT_MATRIX_3 : return "mat3";
|
---|
| 418 | case FLOAT_MATRIX_4 : return "mat4";
|
---|
| 419 | case INT_VECTOR_2 : return "ivec2";
|
---|
| 420 | case INT_VECTOR_3 : return "ivec3";
|
---|
| 421 | case INT_VECTOR_4 : return "ivec4";
|
---|
| 422 | default : return "error";
|
---|
| 423 | }
|
---|
| 424 | }
|
---|