Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Imgui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Silvio Roggentin
Imgui
Commits
88255456
Commit
88255456
authored
10 years ago
by
ocornut
Browse files
Options
Downloads
Patches
Plain Diff
Portability fixes to OpenGL example application (courtesy of djoshea)
parent
150ad95b
No related branches found
Branches containing commit
Tags
v1.02
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/opengl_example/main.cpp
+12
-10
12 additions, 10 deletions
examples/opengl_example/main.cpp
with
12 additions
and
10 deletions
examples/opengl_example/main.cpp
+
12
−
10
View file @
88255456
...
...
@@ -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
);
}
glUnmapBuffer
(
GL_ARRAY_BUFFER
);
// Setup render state: alpha-blending enabled, no face culling, no depth testing
glEnable
(
GL_BLEND
);
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
const
float
width
=
ImGui
::
GetIO
().
DisplaySize
.
x
;
const
float
height
=
ImGui
::
GetIO
().
DisplaySize
.
y
;
const
float
mvp
[
4
][
4
]
=
const
float
mvp
[
4
][
4
]
=
{
{
2.0
f
/
width
,
0.0
f
,
0.0
f
,
0.0
f
},
{
0.0
f
,
2.0
f
/-
height
,
0.0
f
,
0.0
f
},
...
...
@@ -149,7 +149,7 @@ const GLchar* fragmentSource =
"out vec4 o_col;"
"void main() {"
" 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
" 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
())
exit
(
1
);
//
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
//
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR,
0
);
//
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MAJOR
,
3
);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MINOR
,
2
);
glfwWindowHint
(
GLFW_OPENGL_PROFILE
,
GLFW_OPENGL_CORE_PROFILE
);
glfwWindowHint
(
GLFW_OPENGL_FORWARD_COMPAT
,
GL_TRUE
);
glfwWindowHint
(
GLFW_REFRESH_RATE
,
60
);
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
);
glfwSetKeyCallback
(
window
,
glfw_key_callback
);
...
...
@@ -207,8 +207,10 @@ void InitGL()
glewExperimental
=
GL_TRUE
;
glewInit
();
GLenum
err
=
GL_NO_ERROR
;
err
=
glGetError
();
IM_ASSERT
(
err
==
GL_NO_ERROR
);
// After calling glewInit() our GL error state may be GL_INVALID_ENUM
const
GLenum
err
=
glGetError
();
(
void
)
err
;
IM_ASSERT
(
err
==
GL_NO_ERROR
||
err
==
GL_INVALID_ENUM
);
}
void
InitImGui
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment