1 // Copyright (c) 2015 Sergio Gonzalez. All rights reserved. 2 // License: https://github.com/serge-rgb/milton#license 3 4 #pragma once 5 6 #include "common.h" 7 #include "system_includes.h" 8 9 #include "gl.h" 10 11 // GL_DEBUG_OUTPUT defines 12 #define GL_DEBUG_OUTPUT 0x92E0 13 14 15 GL_DEBUG_CALLBACK(milton_gl_debug_callback); 16 17 #if defined(_WIN32) 18 // Declaring glMinSampleShadingARB because we have a different path for loading it. 19 typedef void glMinSampleShadingARBProc (GLclampf value); extern glMinSampleShadingARBProc* glMinSampleShadingARB; 20 #endif //_WIN32 21 22 23 enum GLHelperFlags 24 { 25 GLHelperFlags_SAMPLE_SHADING = 1<<0, 26 GLHelperFlags_TEXTURE_MULTISAMPLE = 1<<1, 27 }; 28 29 namespace gl { 30 31 bool check_flags (int flags); 32 33 bool load (); 34 void log (char* str); 35 GLuint compile_shader (const char* src, GLuint type, char* config = "", char* variation_config = ""); 36 void link_program (GLuint obj, GLuint shaders[], int64_t num_shaders); 37 void use_program(GLuint program); 38 39 40 bool set_attribute_vec2 (GLuint program, char* name, GLfloat* data, size_t data_sz); 41 bool set_uniform_vec4 (GLuint program, char* name, size_t count, float* vals); 42 bool set_uniform_vec4 (GLuint program, char* name, size_t count, float* vals); 43 bool set_uniform_vec3i (GLuint program, char* name, size_t count, i32* vals); 44 bool set_uniform_vec3 (GLuint program, char* name, size_t count, float* vals); 45 bool set_uniform_vec2 (GLuint program, char* name, size_t count, float* vals); 46 bool set_uniform_vec2 (GLuint program, char* name, float x, float y); 47 bool set_uniform_vec2i (GLuint program, char* name, size_t count, i32* vals); 48 bool set_uniform_f (GLuint program, char* name, float val); 49 bool set_uniform_i (GLuint program, char* name, i32 val); 50 bool set_uniform_vec2i (GLuint program, char* name, i32 x, i32 y); 51 bool set_uniform_mat2 (GLuint program, char* name, f32* vals); 52 53 void vertex_attrib_v3f(GLuint program, char* name); 54 55 GLuint new_color_texture (int w, int h); 56 GLuint new_depth_stencil_texture (int w, int h); 57 GLuint new_fbo (GLuint color_attachment, GLuint depth_stencil_attachment=0, GLenum texture_target=GL_TEXTURE_2D); 58 59 #if MULTISAMPLING_ENABLED 60 GLuint new_color_texture_multisample (int w, int h); 61 GLuint new_depth_stencil_texture_multisample (int w, int h); 62 void resize_color_texture_multisample (GLuint t, int w, int h); 63 void resize_depth_stencil_texture_multisample (GLuint t, int w, int h); 64 #endif 65 66 void resize_color_texture (GLuint t, int w, int h); 67 void resize_depth_stencil_texture (GLuint t, int w, int h); 68 69 #if GRAPHICS_DEBUG 70 #define PUSH_GRAPHICS_GROUP(groupName) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, groupName) 71 #define POP_GRAPHICS_GROUP() glPopDebugGroup() 72 #else 73 #define PUSH_GRAPHICS_GROUP(groupName) 74 #define POP_GRAPHICS_GROUP() 75 #endif 76 77 } // namespace gl 78 79