Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glfw
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pirvi-public
glfw
Commits
1a250234
Commit
1a250234
authored
7 years ago
by
Camilla Löwy
Browse files
Options
Downloads
Patches
Plain Diff
Add revert button to gamma ramp test
parent
3169179d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/gamma.c
+24
-2
24 additions, 2 deletions
tests/gamma.c
with
24 additions
and
2 deletions
tests/gamma.c
+
24
−
2
View file @
1a250234
...
...
@@ -38,6 +38,7 @@
#define NK_INCLUDE_DEFAULT_ALLOCATOR
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
#define NK_INCLUDE_STANDARD_VARARGS
#define NK_BUTTON_TRIGGER_ON_RELEASE
#include
<nuklear.h>
#define NK_GLFW_GL2_IMPLEMENTATION
...
...
@@ -85,6 +86,7 @@ int main(int argc, char** argv)
{
GLFWmonitor
*
monitor
=
NULL
;
GLFWwindow
*
window
;
GLFWgammaramp
orig_ramp
;
struct
nk_context
*
nk
;
struct
nk_font_atlas
*
atlas
;
float
gamma_value
=
1
.
f
;
...
...
@@ -103,6 +105,18 @@ int main(int argc, char** argv)
exit
(
EXIT_FAILURE
);
}
{
const
GLFWgammaramp
*
ramp
=
glfwGetGammaRamp
(
monitor
);
const
size_t
array_size
=
ramp
->
size
*
sizeof
(
short
);
orig_ramp
.
size
=
ramp
->
size
;
orig_ramp
.
red
=
malloc
(
array_size
);
orig_ramp
.
green
=
malloc
(
array_size
);
orig_ramp
.
blue
=
malloc
(
array_size
);
memcpy
(
orig_ramp
.
red
,
ramp
->
red
,
array_size
);
memcpy
(
orig_ramp
.
green
,
ramp
->
green
,
array_size
);
memcpy
(
orig_ramp
.
blue
,
ramp
->
blue
,
array_size
);
}
glfwMakeContextCurrent
(
window
);
gladLoadGLLoader
((
GLADloadproc
)
glfwGetProcAddress
);
glfwSwapInterval
(
1
);
...
...
@@ -125,13 +139,17 @@ int main(int argc, char** argv)
nk_glfw3_new_frame
();
if
(
nk_begin
(
nk
,
""
,
area
,
0
))
{
const
GLFWgammaramp
*
ramp
=
glfwGetGammaRamp
(
monitor
)
;
const
GLFWgammaramp
*
ramp
;
nk_window_set_bounds
(
nk
,
area
);
nk_layout_row_dynamic
(
nk
,
30
,
2
);
nk_layout_row_dynamic
(
nk
,
30
,
3
);
if
(
nk_slider_float
(
nk
,
0
.
1
f
,
&
gamma_value
,
5
.
f
,
0
.
1
f
))
glfwSetGamma
(
monitor
,
gamma_value
);
nk_labelf
(
nk
,
NK_TEXT_LEFT
,
"%0.1f"
,
gamma_value
);
if
(
nk_button_label
(
nk
,
"Revert"
))
glfwSetGammaRamp
(
monitor
,
&
orig_ramp
);
ramp
=
glfwGetGammaRamp
(
monitor
);
nk_layout_row_dynamic
(
nk
,
height
-
60
.
f
,
3
);
chart_ramp_array
(
nk
,
nk_rgb
(
255
,
0
,
0
),
ramp
->
size
,
ramp
->
red
);
...
...
@@ -146,6 +164,10 @@ int main(int argc, char** argv)
glfwWaitEventsTimeout
(
1
.
0
);
}
free
(
orig_ramp
.
red
);
free
(
orig_ramp
.
green
);
free
(
orig_ramp
.
blue
);
nk_glfw3_shutdown
();
glfwTerminate
();
exit
(
EXIT_SUCCESS
);
...
...
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