Go to the documentation of this file.
53 #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
54 #define _CRT_SECURE_NO_WARNINGS
61 #if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
66 #if defined(__APPLE__)
67 #include "TargetConditionals.h"
72 #if (defined(__APPLE__) && TARGET_OS_IOS) || (defined(__ANDROID__)) || (defined(__EMSCRIPTEN__))
78 #include <GLES3/gl3.h>
84 #if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
86 #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
88 #elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
92 #include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
112 if (glsl_version ==
NULL)
113 glsl_version =
"#version 300 es";
115 if (glsl_version ==
NULL)
116 glsl_version =
"#version 130";
145 if (fb_width <= 0 || fb_height <= 0)
154 #ifdef GL_SAMPLER_BINDING
159 #ifdef GL_POLYGON_MODE
174 bool clip_origin_lower_left =
true;
175 #ifdef GL_CLIP_ORIGIN
178 clip_origin_lower_left =
false;
188 #ifdef GL_POLYGON_MODE
199 const float ortho_projection[4][4] =
201 { 2.0f/(
R-L), 0.0
f, 0.0
f, 0.0
f },
202 { 0.0f, 2.0f/(T-B), 0.0
f, 0.0
f },
203 { 0.0f, 0.0f, -1.0f, 0.0f },
204 { (
R+L)/(L-
R), (T+B)/(B-T), 0.0f, 1.0f },
209 #ifdef GL_SAMPLER_BINDING
238 for (
int cmd_i = 0; cmd_i < cmd_list->
CmdBuffer.
Size; cmd_i++)
249 if (clip_rect.
x < fb_width && clip_rect.
y < fb_height && clip_rect.
z >= 0.0f && clip_rect.
w >= 0.0f)
252 if (clip_origin_lower_left)
253 glScissor((
int)clip_rect.
x, (
int)(fb_height - clip_rect.
w), (
int)(clip_rect.
z - clip_rect.
x), (
int)(clip_rect.
w - clip_rect.
y));
255 glScissor((
int)clip_rect.
x, (
int)clip_rect.
y, (
int)clip_rect.
z, (
int)clip_rect.
w);
270 #ifdef GL_SAMPLER_BINDING
277 glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
282 #ifdef GL_POLYGON_MODE
286 glScissor(last_scissor_box[0], last_scissor_box[1], (
GLsizei)last_scissor_box[2], (
GLsizei)last_scissor_box[3]);
293 unsigned char* pixels;
330 GLint status = 0, log_length = 0;
334 fprintf(stderr,
"ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
338 buf.
resize((
int)(log_length + 1));
340 fprintf(stderr,
"%s\n", buf.
begin());
348 GLint status = 0, log_length = 0;
352 fprintf(stderr,
"ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc,
g_GlslVersionString);
356 buf.
resize((
int)(log_length + 1));
358 fprintf(stderr,
"%s\n", buf.
begin());
366 GLint last_texture, last_array_buffer, last_vertex_array;
372 int glsl_version = 130;
375 const GLchar* vertex_shader_glsl_120 =
376 "uniform mat4 ProjMtx;\n"
377 "attribute vec2 Position;\n"
378 "attribute vec2 UV;\n"
379 "attribute vec4 Color;\n"
380 "varying vec2 Frag_UV;\n"
381 "varying vec4 Frag_Color;\n"
385 " Frag_Color = Color;\n"
386 " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
389 const GLchar* vertex_shader_glsl_130 =
390 "uniform mat4 ProjMtx;\n"
391 "in vec2 Position;\n"
394 "out vec2 Frag_UV;\n"
395 "out vec4 Frag_Color;\n"
399 " Frag_Color = Color;\n"
400 " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
403 const GLchar* vertex_shader_glsl_300_es =
404 "precision mediump float;\n"
405 "layout (location = 0) in vec2 Position;\n"
406 "layout (location = 1) in vec2 UV;\n"
407 "layout (location = 2) in vec4 Color;\n"
408 "uniform mat4 ProjMtx;\n"
409 "out vec2 Frag_UV;\n"
410 "out vec4 Frag_Color;\n"
414 " Frag_Color = Color;\n"
415 " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
418 const GLchar* vertex_shader_glsl_410_core =
419 "layout (location = 0) in vec2 Position;\n"
420 "layout (location = 1) in vec2 UV;\n"
421 "layout (location = 2) in vec4 Color;\n"
422 "uniform mat4 ProjMtx;\n"
423 "out vec2 Frag_UV;\n"
424 "out vec4 Frag_Color;\n"
428 " Frag_Color = Color;\n"
429 " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
432 const GLchar* fragment_shader_glsl_120 =
434 " precision mediump float;\n"
436 "uniform sampler2D Texture;\n"
437 "varying vec2 Frag_UV;\n"
438 "varying vec4 Frag_Color;\n"
441 " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
444 const GLchar* fragment_shader_glsl_130 =
445 "uniform sampler2D Texture;\n"
447 "in vec4 Frag_Color;\n"
448 "out vec4 Out_Color;\n"
451 " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
454 const GLchar* fragment_shader_glsl_300_es =
455 "precision mediump float;\n"
456 "uniform sampler2D Texture;\n"
458 "in vec4 Frag_Color;\n"
459 "layout (location = 0) out vec4 Out_Color;\n"
462 " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
465 const GLchar* fragment_shader_glsl_410_core =
467 "in vec4 Frag_Color;\n"
468 "uniform sampler2D Texture;\n"
469 "layout (location = 0) out vec4 Out_Color;\n"
472 " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
478 if (glsl_version < 130)
480 vertex_shader = vertex_shader_glsl_120;
481 fragment_shader = fragment_shader_glsl_120;
483 else if (glsl_version >= 410)
485 vertex_shader = vertex_shader_glsl_410_core;
486 fragment_shader = fragment_shader_glsl_410_core;
488 else if (glsl_version == 300)
490 vertex_shader = vertex_shader_glsl_300_es;
491 fragment_shader = fragment_shader_glsl_300_es;
495 vertex_shader = vertex_shader_glsl_130;
496 fragment_shader = fragment_shader_glsl_130;
#define glUniformMatrix4fv
static int g_AttribLocationTex
#define GL_BLEND_SRC_ALPHA
#define GL_ONE_MINUS_SRC_ALPHA
ImVector< ImDrawIdx > IdxBuffer
#define glBlendEquationSeparate
#define GL_COMPILE_STATUS
#define GL_CURRENT_PROGRAM
#define glGetAttribLocation
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData *draw_data)
static GLuint g_FontTexture
#define glGetShaderInfoLog
ImVec2 DisplayFramebufferScale
void ImGui_ImplOpenGL3_DestroyFontsTexture()
static int g_AttribLocationProjMtx
void ImGui_ImplOpenGL3_Shutdown()
bool ImGui_ImplOpenGL3_Init(const char *glsl_version)
bool ImGui_ImplOpenGL3_CreateDeviceObjects()
static char g_GlslVersionString[32]
IMGUI_API ImGuiIO & GetIO()
#define glBlendFuncSeparate
#define GL_ACTIVE_TEXTURE
ImVector< ImDrawCmd > CmdBuffer
IMGUI_API void ScaleClipRects(const ImVec2 &sc)
ImDrawCallback UserCallback
#define GL_UNPACK_ROW_LENGTH
#define GL_SAMPLER_BINDING
#define GL_BLEND_EQUATION_ALPHA
#define GL_FRONT_AND_BACK
#define IM_OFFSETOF(_TYPE, _MEMBER)
#define IM_ARRAYSIZE(_ARR)
#define glDeleteVertexArrays
#define glEnableVertexAttribArray
static unsigned int g_VboHandle
#define GL_TEXTURE_MAG_FILTER
#define GL_FRAGMENT_SHADER
ImVector< ImDrawVert > VtxBuffer
#define glGetUniformLocation
#define glGetProgramInfoLog
#define GL_TEXTURE_MIN_FILTER
#define GL_BLEND_EQUATION_RGB
#define GL_ARRAY_BUFFER_BINDING
#define glVertexAttribPointer
#define GL_ELEMENT_ARRAY_BUFFER
static bool CheckProgram(GLuint handle, const char *desc)
void resize(int new_size)
static unsigned int g_ElementsHandle
#define GL_BLEND_DST_ALPHA
const char * BackendRendererName
#define GL_INFO_LOG_LENGTH
static GLuint g_VertHandle
#define GL_UNSIGNED_SHORT
static int g_AttribLocationUV
#define glGenVertexArrays
void ImGui_ImplOpenGL3_DestroyDeviceObjects()
#define GL_TEXTURE_BINDING_2D
void ImGui_ImplOpenGL3_NewFrame()
khronos_ssize_t GLsizeiptr
#define glBindVertexArray
static bool CheckShader(GLuint handle, const char *desc)
bool ImGui_ImplOpenGL3_CreateFontsTexture()
static int g_AttribLocationPosition
static GLuint g_ShaderHandle
static int g_AttribLocationColor
static GLuint g_FragHandle
#define GL_VERTEX_ARRAY_BINDING
IMGUI_API void GetTexDataAsRGBA32(unsigned char **out_pixels, int *out_width, int *out_height, int *out_bytes_per_pixel=NULL)
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07