mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 03:47:00 +00:00
Portability fixes to OpenGL example application (courtesy of djoshea)
This commit is contained in:
parent
150ad95bd6
commit
8825545653
@ -39,7 +39,7 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
|
|||||||
buffer_data += cmd_list->vtx_buffer.size() * sizeof(ImDrawVert);
|
buffer_data += cmd_list->vtx_buffer.size() * sizeof(ImDrawVert);
|
||||||
}
|
}
|
||||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||||
|
|
||||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing
|
// Setup render state: alpha-blending enabled, no face culling, no depth testing
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
@ -55,7 +55,7 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
|
|||||||
// Setup orthographic projection matrix
|
// Setup orthographic projection matrix
|
||||||
const float width = ImGui::GetIO().DisplaySize.x;
|
const float width = ImGui::GetIO().DisplaySize.x;
|
||||||
const float height = ImGui::GetIO().DisplaySize.y;
|
const float height = ImGui::GetIO().DisplaySize.y;
|
||||||
const float mvp[4][4] =
|
const float mvp[4][4] =
|
||||||
{
|
{
|
||||||
{ 2.0f/width, 0.0f, 0.0f, 0.0f },
|
{ 2.0f/width, 0.0f, 0.0f, 0.0f },
|
||||||
{ 0.0f, 2.0f/-height, 0.0f, 0.0f },
|
{ 0.0f, 2.0f/-height, 0.0f, 0.0f },
|
||||||
@ -149,7 +149,7 @@ const GLchar* fragmentSource =
|
|||||||
"out vec4 o_col;"
|
"out vec4 o_col;"
|
||||||
"void main() {"
|
"void main() {"
|
||||||
" o_col = texture(Tex, uv) * col;"
|
" o_col = texture(Tex, uv) * col;"
|
||||||
//" if (pixel_pos.x < ClipRect.x || pixel_pos.y < ClipRect.y || pixel_pos.x > ClipRect.z || pixel_pos.y > ClipRect.w) discard;" // Clipping: using discard
|
//" if (pixel_pos.x < ClipRect.x || pixel_pos.y < ClipRect.y || pixel_pos.x > ClipRect.z || pixel_pos.y > ClipRect.w) discard;" // Clipping: using discard
|
||||||
//" if (step(ClipRect.x,pixel_pos.x) * step(ClipRect.y,pixel_pos.y) * step(pixel_pos.x,ClipRect.z) * step(pixel_pos.y,ClipRect.w) < 1.0f) discard;" // Clipping: using discard and step
|
//" if (step(ClipRect.x,pixel_pos.x) * step(ClipRect.y,pixel_pos.y) * step(pixel_pos.x,ClipRect.z) * step(pixel_pos.y,ClipRect.w) < 1.0f) discard;" // Clipping: using discard and step
|
||||||
" o_col.w *= (step(ClipRect.x,pixel_pos.x) * step(ClipRect.y,pixel_pos.y) * step(pixel_pos.x,ClipRect.z) * step(pixel_pos.y,ClipRect.w));" // Clipping: branch-less, set alpha 0.0f
|
" o_col.w *= (step(ClipRect.x,pixel_pos.x) * step(ClipRect.y,pixel_pos.y) * step(pixel_pos.x,ClipRect.z) * step(pixel_pos.y,ClipRect.w));" // Clipping: branch-less, set alpha 0.0f
|
||||||
"}";
|
"}";
|
||||||
@ -191,13 +191,13 @@ void InitGL()
|
|||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
//glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
//glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||||
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||||
glfwWindowHint(GLFW_REFRESH_RATE, 60);
|
glfwWindowHint(GLFW_REFRESH_RATE, 60);
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
||||||
window = glfwCreateWindow(1280, 720, "ImGui OpenGL example", nullptr, nullptr);
|
window = glfwCreateWindow(1280, 720, "ImGui OpenGL example", NULL, NULL);
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
glfwSetKeyCallback(window, glfw_key_callback);
|
glfwSetKeyCallback(window, glfw_key_callback);
|
||||||
@ -207,8 +207,10 @@ void InitGL()
|
|||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
glewInit();
|
glewInit();
|
||||||
|
|
||||||
GLenum err = GL_NO_ERROR;
|
// After calling glewInit() our GL error state may be GL_INVALID_ENUM
|
||||||
err = glGetError(); IM_ASSERT(err == GL_NO_ERROR);
|
const GLenum err = glGetError();
|
||||||
|
(void)err;
|
||||||
|
IM_ASSERT(err == GL_NO_ERROR || err == GL_INVALID_ENUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitImGui()
|
void InitImGui()
|
||||||
|
Loading…
Reference in New Issue
Block a user