Skip to content

Commit 4cf06d6

Browse files
committed
Updated dear imgui to 1.78 (src)
1 parent 10b1184 commit 4cf06d6

File tree

13 files changed

+5932
-3892
lines changed

13 files changed

+5932
-3892
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Nuparu currently consists of:
2828
* [blosc](https://github.com/Blosc) 1.20.1 (Mac/Win/Linux)
2929
* [Protobuf](https://developers.google.com/protocol-buffers/) 3.13.0 (Mac/Win/Linux)
3030
* [ispc](https://ispc.github.io) 1.14.1 (Mac/Win/Linux)
31-
* [dear imgui](https://github.com/ocornut/imgui/releases) 1.75 (Src)
31+
* [dear imgui](https://github.com/ocornut/imgui/releases) 1.78 (Src)
3232
* [imnodes](https://github.com/Nelarius/imnodes) 0.2 (Src)
3333

3434
Notes:

src/imgui/imconfig.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
2727
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2828

29-
//---- Disable all of Dear ImGui or don't implement standard windows.
29+
//---- Disable all of Dear ImGui or don't implement standard windows.
3030
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
31-
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
32-
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
31+
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
32+
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
3333
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
3434

3535
//---- Don't implement some functions to reduce linkage requirements.
@@ -48,6 +48,9 @@
4848
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
4949
//#define IMGUI_USE_BGRA_PACKED_COLOR
5050

51+
//---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
52+
//#define IMGUI_USE_WCHAR32
53+
5154
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
5255
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
5356
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"

src/imgui/imgui.cpp

Lines changed: 1982 additions & 1541 deletions
Large diffs are not rendered by default.

src/imgui/imgui.h

Lines changed: 392 additions & 216 deletions
Large diffs are not rendered by default.

src/imgui/imgui_demo.cpp

Lines changed: 1272 additions & 712 deletions
Large diffs are not rendered by default.

src/imgui/imgui_draw.cpp

Lines changed: 703 additions & 368 deletions
Large diffs are not rendered by default.

src/imgui/imgui_impl_glfw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ enum GlfwClientApi
6868
static GLFWwindow* g_Window = NULL; // Main window
6969
static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
7070
static double g_Time = 0.0;
71-
static bool g_MouseJustPressed[5] = { false, false, false, false, false };
71+
static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {};
7272
static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
7373
static bool g_InstalledCallbacks = false;
7474

@@ -358,7 +358,7 @@ void ImGui_ImplGlfw_NewFrame()
358358

359359
// Setup time step
360360
double current_time = glfwGetTime();
361-
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f/60.0f);
361+
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
362362
g_Time = current_time;
363363

364364
ImGui_ImplGlfw_UpdateMousePosAndButtons();

src/imgui/imgui_impl_glfw.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure!
1818

1919
#pragma once
20+
#include "imgui.h" // IMGUI_IMPL_API
2021

2122
struct GLFWwindow;
2223

@@ -25,8 +26,9 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool in
2526
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
2627
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
2728

28-
// InitXXX function with 'install_callbacks=true': install GLFW callbacks. They will call user's previously installed callbacks, if any.
29-
// InitXXX function with 'install_callbacks=false': do not install GLFW callbacks. You will need to call them yourself from your own GLFW callbacks.
29+
// GLFW callbacks
30+
// - When calling Init with 'install_callbacks=true': GLFW callbacks will be installed for you. They will call user's previously installed callbacks, if any.
31+
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call those function yourself from your own GLFW callbacks.
3032
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
3133
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
3234
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);

src/imgui/imgui_impl_opengl3.cpp

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@
1313

1414
// CHANGELOG
1515
// (minor and older changes stripped away, please see git history for details)
16-
// 2020-01-07: OpenGL: Added support for glbindings OpenGL loader.
16+
// 2020-07-10: OpenGL: Added support for glad2 OpenGL loader.
17+
// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
18+
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
19+
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
20+
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
21+
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
1722
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
1823
// 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility.
1924
// 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call.
2025
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
2126
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
2227
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
23-
// 2019-03-15: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
28+
// 2019-03-15: OpenGL: Added a GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
2429
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
2530
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
2631
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
@@ -75,28 +80,7 @@
7580
#else
7681
#include <stdint.h> // intptr_t
7782
#endif
78-
#if defined(__APPLE__)
79-
#include "TargetConditionals.h"
80-
#endif
8183

82-
// Auto-enable GLES on matching platforms
83-
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
84-
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
85-
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
86-
#undef IMGUI_IMPL_OPENGL_LOADER_GL3W
87-
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
88-
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
89-
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING
90-
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
91-
#elif defined(__EMSCRIPTEN__)
92-
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
93-
#undef IMGUI_IMPL_OPENGL_LOADER_GL3W
94-
#undef IMGUI_IMPL_OPENGL_LOADER_GLEW
95-
#undef IMGUI_IMPL_OPENGL_LOADER_GLAD
96-
#undef IMGUI_IMPL_OPENGL_LOADER_GLBINDING
97-
#undef IMGUI_IMPL_OPENGL_LOADER_CUSTOM
98-
#endif
99-
#endif
10084

10185
// GL includes
10286
#if defined(IMGUI_IMPL_OPENGL_ES2)
@@ -113,14 +97,26 @@
11397
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
11498
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
11599
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
116-
#include <GL/gl3w.h> // Needs to be initialized with gl3wInit() in user's code
100+
#include <GL/gl3w.h> // Needs to be initialized with gl3wInit() in user's code
117101
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
118-
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code
102+
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code.
119103
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
120-
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code
121-
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING)
122-
#include <glbinding/gl/gl.h> // Initialize with glbinding::initialize()
123-
#include <glbinding/glbinding.h>
104+
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
105+
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
106+
#include <glad/gl.h> // Needs to be initialized with gladLoadGL(...) or gladLoaderLoadGL() in user's code.
107+
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
108+
#ifndef GLFW_INCLUDE_NONE
109+
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
110+
#endif
111+
#include <glbinding/Binding.h> // Needs to be initialized with glbinding::Binding::initialize() in user's code.
112+
#include <glbinding/gl/gl.h>
113+
using namespace gl;
114+
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
115+
#ifndef GLFW_INCLUDE_NONE
116+
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
117+
#endif
118+
#include <glbinding/glbinding.h>// Needs to be initialized with glbinding::initialize() in user's code.
119+
#include <glbinding/gl/gl.h>
124120
using namespace gl;
125121
#else
126122
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
@@ -135,32 +131,32 @@ using namespace gl;
135131
#endif
136132

137133
// OpenGL Data
138-
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries.
134+
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
139135
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
140136
static GLuint g_FontTexture = 0;
141137
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
142-
static int g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
143-
static int g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
138+
static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
139+
static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
144140
static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
145141

146142
// Functions
147143
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
148144
{
149-
// Query for GL version
145+
// Query for GL version (e.g. 320 for GL 3.2)
150146
#if !defined(IMGUI_IMPL_OPENGL_ES2)
151147
GLint major, minor;
152148
glGetIntegerv(GL_MAJOR_VERSION, &major);
153149
glGetIntegerv(GL_MINOR_VERSION, &minor);
154-
g_GlVersion = major * 1000 + minor;
150+
g_GlVersion = (GLuint)(major * 100 + minor * 10);
155151
#else
156-
g_GlVersion = 2000; // GLES 2
152+
g_GlVersion = 200; // GLES 2
157153
#endif
158154

159155
// Setup back-end capabilities flags
160156
ImGuiIO& io = ImGui::GetIO();
161157
io.BackendRendererName = "imgui_impl_opengl3";
162158
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
163-
if (g_GlVersion >= 3200)
159+
if (g_GlVersion >= 320)
164160
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
165161
#endif
166162

@@ -172,6 +168,9 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
172168
#elif defined(IMGUI_IMPL_OPENGL_ES3)
173169
if (glsl_version == NULL)
174170
glsl_version = "#version 300 es";
171+
#elif defined(__APPLE__)
172+
if (glsl_version == NULL)
173+
glsl_version = "#version 150";
175174
#else
176175
if (glsl_version == NULL)
177176
glsl_version = "#version 130";
@@ -180,7 +179,7 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
180179
strcpy(g_GlslVersionString, glsl_version);
181180
strcat(g_GlslVersionString, "\n");
182181

183-
// Dummy construct to make it easily visible in the IDE and debugger which GL loader has been selected.
182+
// Debugging construct to make it easily visible in the IDE and debugger which GL loader has been selected.
184183
// The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
185184
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
186185
// you are likely to get a crash below.
@@ -193,13 +192,19 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
193192
gl_loader = "GLEW";
194193
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
195194
gl_loader = "GLAD";
196-
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING)
197-
gl_loader = "glbinding";
198-
#else // IMGUI_IMPL_OPENGL_LOADER_CUSTOM
199-
gl_loader = "Custom";
195+
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD2)
196+
gl_loader = "GLAD2";
197+
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
198+
gl_loader = "glbinding2";
199+
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
200+
gl_loader = "glbinding3";
201+
#elif defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
202+
gl_loader = "custom";
203+
#else
204+
gl_loader = "none";
200205
#endif
201206

202-
// Make a dummy GL call (we don't actually need the result)
207+
// Make an arbitrary GL call (we don't actually need the result)
203208
// IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
204209
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
205210
GLint current_texture;
@@ -232,13 +237,22 @@ static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_wid
232237
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
233238
#endif
234239

240+
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
241+
bool clip_origin_lower_left = true;
242+
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
243+
GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&current_clip_origin);
244+
if (current_clip_origin == GL_UPPER_LEFT)
245+
clip_origin_lower_left = false;
246+
#endif
247+
235248
// Setup viewport, orthographic projection matrix
236249
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
237250
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
238251
float L = draw_data->DisplayPos.x;
239252
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
240253
float T = draw_data->DisplayPos.y;
241254
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
255+
if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
242256
const float ortho_projection[4][4] =
243257
{
244258
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
@@ -283,14 +297,14 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
283297
// Backup GL state
284298
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
285299
glActiveTexture(GL_TEXTURE0);
286-
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
287-
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
300+
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
301+
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
288302
#ifdef GL_SAMPLER_BINDING
289-
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
303+
GLuint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler);
290304
#endif
291-
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
305+
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
292306
#ifndef IMGUI_IMPL_OPENGL_ES2
293-
GLint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array_object);
307+
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
294308
#endif
295309
#ifdef GL_POLYGON_MODE
296310
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
@@ -307,12 +321,6 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
307321
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
308322
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
309323
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
310-
bool clip_origin_lower_left = true;
311-
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
312-
GLenum last_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)&last_clip_origin); // Support for GL 4.5's glClipControl(GL_UPPER_LEFT)
313-
if (last_clip_origin == GL_UPPER_LEFT)
314-
clip_origin_lower_left = false;
315-
#endif
316324

317325
// Setup desired GL state
318326
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
@@ -333,8 +341,8 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
333341
const ImDrawList* cmd_list = draw_data->CmdLists[n];
334342

335343
// Upload vertex/index buffers
336-
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
337-
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
344+
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
345+
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
338346

339347
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
340348
{
@@ -360,15 +368,12 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
360368
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
361369
{
362370
// Apply scissor/clipping rectangle
363-
if (clip_origin_lower_left)
364-
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));
365-
else
366-
glScissor((int)clip_rect.x, (int)clip_rect.y, (int)clip_rect.z, (int)clip_rect.w); // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
371+
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));
367372

368373
// Bind texture, Draw
369374
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
370375
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
371-
if (g_GlVersion >= 3200)
376+
if (g_GlVersion >= 320)
372377
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
373378
else
374379
#endif
@@ -643,9 +648,9 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
643648

644649
g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
645650
g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
646-
g_AttribLocationVtxPos = glGetAttribLocation(g_ShaderHandle, "Position");
647-
g_AttribLocationVtxUV = glGetAttribLocation(g_ShaderHandle, "UV");
648-
g_AttribLocationVtxColor = glGetAttribLocation(g_ShaderHandle, "Color");
651+
g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position");
652+
g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV");
653+
g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color");
649654

650655
// Create buffers
651656
glGenBuffers(1, &g_VboHandle);

0 commit comments

Comments
 (0)