mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Merge branch 'master' into docking
# Conflicts: # examples/imgui_impl_opengl3.cpp
This commit is contained in:
commit
49eb5f0280
@ -105,7 +105,7 @@ Breaking Changes:
|
|||||||
|
|
||||||
Other Changes:
|
Other Changes:
|
||||||
|
|
||||||
- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigation to the menu layer.
|
- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigating to the menu layer.
|
||||||
- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types.
|
- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types.
|
||||||
We are reusing function instances for larger types to reduce code size. (#643, #320, #708, #1011)
|
We are reusing function instances for larger types to reduce code size. (#643, #320, #708, #1011)
|
||||||
- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when
|
- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when
|
||||||
@ -118,6 +118,8 @@ Other Changes:
|
|||||||
- InputText: Fixed various display corruption related to swapping the underlying buffer while
|
- InputText: Fixed various display corruption related to swapping the underlying buffer while
|
||||||
a input widget is active (both for writable and read-only paths). Often they would manifest
|
a input widget is active (both for writable and read-only paths). Often they would manifest
|
||||||
when manipulating the scrollbar of a multi-line input text.
|
when manipulating the scrollbar of a multi-line input text.
|
||||||
|
- ColorPicker: Fixed a bug/assertion when displaying a color picker in a collapsed window
|
||||||
|
while dragging its title bar. (#2389)
|
||||||
- TabBar: Fixed a crash when using BeginTabBar() recursively (didn't affect docking). (#2371)
|
- TabBar: Fixed a crash when using BeginTabBar() recursively (didn't affect docking). (#2371)
|
||||||
- TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to
|
- TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to
|
||||||
hard crashes any more, facilitating integration with scripting languages. (#1651)
|
hard crashes any more, facilitating integration with scripting languages. (#1651)
|
||||||
@ -127,6 +129,8 @@ Other Changes:
|
|||||||
- Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute
|
- Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute
|
||||||
tree depth instead of a relative one.
|
tree depth instead of a relative one.
|
||||||
- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##".
|
- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##".
|
||||||
|
- Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f).
|
||||||
|
- Examples: OpenGL: Fix to be able to run on ES 2.0 / WebGL 1.0. [@rmitton, @gabrielcuvillier]
|
||||||
- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN
|
- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN
|
||||||
even if the OpenGL headers/loader happens to define the value. (#2366, #2186)
|
even if the OpenGL headers/loader happens to define the value. (#2366, #2186)
|
||||||
- Examples: Allegro: Added support for touch events (emulating mouse). (#2219) [@dos1]
|
- Examples: Allegro: Added support for touch events (emulating mouse). (#2219) [@dos1]
|
||||||
|
@ -118,8 +118,8 @@ List of Renderer Bindings in this repository:
|
|||||||
imgui_impl_dx11.cpp ; DirectX11
|
imgui_impl_dx11.cpp ; DirectX11
|
||||||
imgui_impl_dx12.cpp ; DirectX12
|
imgui_impl_dx12.cpp ; DirectX12
|
||||||
imgui_impl_metal.mm ; Metal (with ObjC)
|
imgui_impl_metal.mm ; Metal (with ObjC)
|
||||||
imgui_impl_opengl2.cpp ; OpenGL2 (legacy, fixed pipeline <- don't use with modern OpenGL context)
|
imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context)
|
||||||
imgui_impl_opengl3.cpp ; OpenGL3, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline)
|
imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline)
|
||||||
imgui_impl_vulkan.cpp ; Vulkan
|
imgui_impl_vulkan.cpp ; Vulkan
|
||||||
|
|
||||||
List of high-level Frameworks Bindings in this repository: (combine Platform + Renderer)
|
List of high-level Frameworks Bindings in this repository: (combine Platform + Renderer)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline)
|
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||||
|
// - Desktop GL: 3.x 4.x
|
||||||
|
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
// (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..)
|
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
@ -13,6 +14,7 @@
|
|||||||
// CHANGELOG
|
// CHANGELOG
|
||||||
// (minor and older changes stripped away, please see git history for details)
|
// (minor and older changes stripped away, please see git history for details)
|
||||||
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
// 2018-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
|
||||||
|
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
||||||
// 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.
|
// 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.
|
||||||
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||||
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
||||||
@ -41,17 +43,17 @@
|
|||||||
// version version string
|
// version version string
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
// 2.0 110 "#version 110"
|
// 2.0 110 "#version 110"
|
||||||
// 2.1 120
|
// 2.1 110 "#version 120"
|
||||||
// 3.0 130
|
// 3.0 130 "#version 130"
|
||||||
// 3.1 140
|
// 3.1 140 "#version 140"
|
||||||
// 3.2 150 "#version 150"
|
// 3.2 150 "#version 150"
|
||||||
// 3.3 330
|
// 3.3 330 "#version 330 core"
|
||||||
// 4.0 400
|
// 4.0 400 "#version 400 core"
|
||||||
// 4.1 410 "#version 410 core"
|
// 4.1 410 "#version 410 core"
|
||||||
// 4.2 420
|
// 4.2 420 "#version 410 core"
|
||||||
// 4.3 430
|
// 4.3 430 "#version 430 core"
|
||||||
// ES 2.0 100 "#version 100"
|
// ES 2.0 100 "#version 100" = WebGL 1.0
|
||||||
// ES 3.0 300 "#version 300 es"
|
// ES 3.0 300 "#version 300 es" = WebGL 2.0
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||||
@ -70,20 +72,24 @@
|
|||||||
#include "TargetConditionals.h"
|
#include "TargetConditionals.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// iOS, Android and Emscripten can use GL ES 3
|
// Auto-detect GL version
|
||||||
// Call ImGui_ImplOpenGL3_Init() with "#version 300 es"
|
#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
#if (defined(__APPLE__) && TARGET_OS_IOS) || (defined(__ANDROID__)) || (defined(__EMSCRIPTEN__))
|
#if (defined(__APPLE__) && TARGET_OS_IOS) || (defined(__ANDROID__))
|
||||||
#define USE_GL_ES3
|
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||||
|
#elif defined(__EMSCRIPTEN__)
|
||||||
|
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_GL_ES3
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
// OpenGL ES 3
|
#include <GLES2/gl2.h>
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
#include <GLES3/gl3.h> // Use GL ES 3
|
#include <GLES3/gl3.h> // Use GL ES 3
|
||||||
#else
|
#else
|
||||||
// Regular OpenGL
|
// About Desktop OpenGL function loaders:
|
||||||
// About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually.
|
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad.
|
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||||
#include <GL/gl3w.h>
|
#include <GL/gl3w.h>
|
||||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||||
@ -116,7 +122,10 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
|||||||
io.BackendRendererName = "imgui_impl_opengl3";
|
io.BackendRendererName = "imgui_impl_opengl3";
|
||||||
|
|
||||||
// Store GLSL version string so we can refer to it later in case we recreate shaders. Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
|
// Store GLSL version string so we can refer to it later in case we recreate shaders. Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
|
||||||
#ifdef USE_GL_ES3
|
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||||
|
if (glsl_version == NULL)
|
||||||
|
glsl_version = "#version 100";
|
||||||
|
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||||
if (glsl_version == NULL)
|
if (glsl_version == NULL)
|
||||||
glsl_version = "#version 300 es";
|
glsl_version = "#version 300 es";
|
||||||
#else
|
#else
|
||||||
@ -165,7 +174,9 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
|
GLint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, &last_sampler);
|
||||||
#endif
|
#endif
|
||||||
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
|
#endif
|
||||||
#ifdef GL_POLYGON_MODE
|
#ifdef GL_POLYGON_MODE
|
||||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||||
#endif
|
#endif
|
||||||
@ -219,11 +230,14 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
#ifdef GL_SAMPLER_BINDING
|
#ifdef GL_SAMPLER_BINDING
|
||||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
// Recreate the VAO every time
|
// Recreate the VAO every time
|
||||||
// (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)
|
// (This is to easily allow multiple GL contexts. VAO are not shared among GL contexts, and we don't track creation/deletion of windows so we don't have an obvious key to use to cache them.)
|
||||||
GLuint vao_handle = 0;
|
GLuint vao_handle = 0;
|
||||||
glGenVertexArrays(1, &vao_handle);
|
glGenVertexArrays(1, &vao_handle);
|
||||||
glBindVertexArray(vao_handle);
|
glBindVertexArray(vao_handle);
|
||||||
|
#endif
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
|
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
|
||||||
glEnableVertexAttribArray(g_AttribLocationPosition);
|
glEnableVertexAttribArray(g_AttribLocationPosition);
|
||||||
glEnableVertexAttribArray(g_AttribLocationUV);
|
glEnableVertexAttribArray(g_AttribLocationUV);
|
||||||
@ -281,7 +295,9 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
idx_buffer_offset += pcmd->ElemCount * sizeof(ImDrawIdx);
|
idx_buffer_offset += pcmd->ElemCount * sizeof(ImDrawIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
glDeleteVertexArrays(1, &vao_handle);
|
glDeleteVertexArrays(1, &vao_handle);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glUseProgram(last_program);
|
glUseProgram(last_program);
|
||||||
@ -290,7 +306,9 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
|||||||
glBindSampler(0, last_sampler);
|
glBindSampler(0, last_sampler);
|
||||||
#endif
|
#endif
|
||||||
glActiveTexture(last_active_texture);
|
glActiveTexture(last_active_texture);
|
||||||
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
glBindVertexArray(last_vertex_array);
|
glBindVertexArray(last_vertex_array);
|
||||||
|
#endif
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
|
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
|
||||||
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
|
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
|
||||||
@ -320,7 +338,9 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
|||||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
#ifdef GL_UNPACK_ROW_LENGTH
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
|
#endif
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
@ -382,10 +402,13 @@ static bool CheckProgram(GLuint handle, const char* desc)
|
|||||||
bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
// Backup GL state
|
// Backup GL state
|
||||||
GLint last_texture, last_array_buffer, last_vertex_array;
|
GLint last_texture, last_array_buffer;
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||||
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
|
GLint last_vertex_array;
|
||||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Parse GLSL version string
|
// Parse GLSL version string
|
||||||
int glsl_version = 130;
|
int glsl_version = 130;
|
||||||
@ -549,7 +572,9 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
|||||||
// Restore modified GL state
|
// Restore modified GL state
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||||
|
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||||
glBindVertexArray(last_vertex_array);
|
glBindVertexArray(last_vertex_array);
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// dear imgui: Renderer for OpenGL3 / OpenGL ES2 / OpenGL ES3 (modern OpenGL with shaders / programmatic pipeline)
|
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||||
|
// - Desktop GL: 3.x 4.x
|
||||||
|
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||||
// (Note: We are using GL3W as a helper library to access OpenGL functions since there is no standard header to access modern OpenGL functions easily. Alternatives are GLEW, Glad, etc..)
|
|
||||||
|
|
||||||
// Implemented features:
|
// Implemented features:
|
||||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
@ -10,19 +11,23 @@
|
|||||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||||
// https://github.com/ocornut/imgui
|
// https://github.com/ocornut/imgui
|
||||||
|
|
||||||
// About OpenGL function loaders:
|
// About Desktop OpenGL function loaders:
|
||||||
// About OpenGL function loaders: modern OpenGL doesn't have a standard header file and requires individual function pointers to be loaded manually.
|
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones: gl3w, glew, glad.
|
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||||
|
|
||||||
// About GLSL version:
|
// About GLSL version:
|
||||||
// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
|
// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
|
||||||
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
|
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
|
||||||
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Set default OpenGL loader to be gl3w
|
// Specific OpenGL versions
|
||||||
|
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
||||||
|
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
||||||
|
|
||||||
|
// Set default OpenGL3 loader to be gl3w
|
||||||
#if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
#if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
||||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
||||||
|
15
imgui.cpp
15
imgui.cpp
@ -1523,27 +1523,27 @@ ImU32 ImHashData(const void* data_p, size_t data_size, ImU32 seed)
|
|||||||
// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
// - If we reach ### in the string we discard the hash so far and reset to the seed.
|
||||||
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
|
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
|
||||||
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
|
||||||
ImU32 ImHashStr(const char* data, size_t data_size, ImU32 seed)
|
ImU32 ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
|
||||||
{
|
{
|
||||||
seed = ~seed;
|
seed = ~seed;
|
||||||
ImU32 crc = seed;
|
ImU32 crc = seed;
|
||||||
const unsigned char* src = (const unsigned char*)data;
|
const unsigned char* data = (const unsigned char*)data_p;
|
||||||
const ImU32* crc32_lut = GCrc32LookupTable;
|
const ImU32* crc32_lut = GCrc32LookupTable;
|
||||||
if (data_size != 0)
|
if (data_size != 0)
|
||||||
{
|
{
|
||||||
while (data_size-- != 0)
|
while (data_size-- != 0)
|
||||||
{
|
{
|
||||||
unsigned char c = *src++;
|
unsigned char c = *data++;
|
||||||
if (c == '#' && src[0] == '#' && src[1] == '#')
|
if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#')
|
||||||
crc = seed;
|
crc = seed;
|
||||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (unsigned char c = *src++)
|
while (unsigned char c = *data++)
|
||||||
{
|
{
|
||||||
if (c == '#' && src[0] == '#' && src[1] == '#')
|
if (c == '#' && data[0] == '#' && data[1] == '#')
|
||||||
crc = seed;
|
crc = seed;
|
||||||
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
|
||||||
}
|
}
|
||||||
@ -3492,12 +3492,13 @@ void ImGui::NewFrame()
|
|||||||
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
|
||||||
IM_ASSERT(g.Initialized);
|
IM_ASSERT(g.Initialized);
|
||||||
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
|
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
|
||||||
|
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
||||||
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
|
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
|
||||||
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||||
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
||||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
||||||
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
|
IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
|
||||||
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
for (int n = 0; n < ImGuiKey_COUNT; n++)
|
||||||
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
|
||||||
|
|
||||||
|
@ -1515,20 +1515,23 @@ static void ShowDemoWindowWidgets()
|
|||||||
static int item_type = 1;
|
static int item_type = 1;
|
||||||
static bool b = false;
|
static bool b = false;
|
||||||
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f };
|
||||||
|
static char str[16] = {};
|
||||||
ImGui::RadioButton("Text", &item_type, 0);
|
ImGui::RadioButton("Text", &item_type, 0);
|
||||||
ImGui::RadioButton("Button", &item_type, 1);
|
ImGui::RadioButton("Button", &item_type, 1);
|
||||||
ImGui::RadioButton("Checkbox", &item_type, 2);
|
ImGui::RadioButton("Checkbox", &item_type, 2);
|
||||||
ImGui::RadioButton("SliderFloat", &item_type, 3);
|
ImGui::RadioButton("SliderFloat", &item_type, 3);
|
||||||
ImGui::RadioButton("ColorEdit4", &item_type, 4);
|
ImGui::RadioButton("InputText", &item_type, 4);
|
||||||
ImGui::RadioButton("ListBox", &item_type, 5);
|
ImGui::RadioButton("ColorEdit4", &item_type, 5);
|
||||||
|
ImGui::RadioButton("ListBox", &item_type, 6);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction
|
||||||
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button
|
||||||
if (item_type == 2) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
|
if (item_type == 2) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox
|
||||||
if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
if (item_type == 3) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item
|
||||||
if (item_type == 4) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
if (item_type == 4) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing)
|
||||||
if (item_type == 5) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
if (item_type == 5) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged)
|
||||||
|
if (item_type == 6) { const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); }
|
||||||
ImGui::BulletText(
|
ImGui::BulletText(
|
||||||
"Return value = %d\n"
|
"Return value = %d\n"
|
||||||
"IsItemFocused() = %d\n"
|
"IsItemFocused() = %d\n"
|
||||||
|
@ -4253,8 +4253,10 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
ImDrawList* draw_list = window->DrawList;
|
if (window->SkipItems)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ImDrawList* draw_list = window->DrawList;
|
||||||
ImGuiStyle& style = g.Style;
|
ImGuiStyle& style = g.Style;
|
||||||
ImGuiIO& io = g.IO;
|
ImGuiIO& io = g.IO;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user