Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MAKE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dave
MAKE
Commits
9cf4035b
Commit
9cf4035b
authored
3 years ago
by
Dave
Browse files
Options
Downloads
Patches
Plain Diff
Minor modifications
parent
d3d4339e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/App.h
+2
-0
2 additions, 0 deletions
include/App.h
resources/shaders/basicFragment.glsl
+6
-9
6 additions, 9 deletions
resources/shaders/basicFragment.glsl
src/App.cpp
+9
-14
9 additions, 14 deletions
src/App.cpp
with
17 additions
and
23 deletions
include/App.h
+
2
−
0
View file @
9cf4035b
...
@@ -44,6 +44,8 @@ private:
...
@@ -44,6 +44,8 @@ private:
Viewport
*
v
;
Viewport
*
v
;
float
frametime
;
bool
ShouldClose
;
bool
ShouldClose
;
public:
public:
...
...
This diff is collapsed.
Click to expand it.
resources/shaders/basicFragment.glsl
+
6
−
9
View file @
9cf4035b
...
@@ -10,10 +10,10 @@ in vec3 pos;
...
@@ -10,10 +10,10 @@ in vec3 pos;
void
main
(){
void
main
(){
vec3
lightColor
=
vec3
(
1
.
0
,
1
.
0
,
1
.
0
);
vec3
lightColor
=
vec3
(
1
.
0
,
1
.
0
,
1
.
0
);
vec3
objectColor
=
vec3
(
0
.
9
);
vec3
objectColor
=
vec3
(
1
.
0
);
// ambient
// ambient
float
ambientStrength
=
0
.
2
;
float
ambientStrength
=
0
.
1
;
vec3
ambient
=
ambientStrength
*
lightColor
;
vec3
ambient
=
ambientStrength
*
lightColor
;
// diffuse
// diffuse
...
@@ -23,13 +23,10 @@ void main(){
...
@@ -23,13 +23,10 @@ void main(){
vec3
diffuse
=
diff
*
lightColor
;
vec3
diffuse
=
diff
*
lightColor
;
// specular
// specular
float
specularStrength
=
0
.
7
;
float
specularStrength
=
0
.
5
;
vec3
viewDir
=
normalize
(
cameraPos
-
pos
);
vec3
viewDir
=
normalize
(
cameraPos
-
pos
);
vec3
reflectDir
=
reflect
(
-
lightDir
,
norm
);
vec3
reflectDir
=
reflect
(
-
lightDir
,
norm
);
float
spec
=
pow
(
max
(
dot
(
viewDir
,
reflectDir
),
0
.
0
),
32
);
float
spec
=
pow
(
max
(
dot
(
viewDir
,
reflectDir
),
0
.
0
),
32
);
vec3
specular
=
specularStrength
*
spec
*
lightColor
;
vec3
specular
=
specularStrength
*
spec
*
lightColor
;
outColor
=
vec4
((
ambient
+
diffuse
+
specular
)
*
objectColor
,
1
.
0
);
vec3
result
=
diffuse
*
objectColor
;
//result = vec3(normal.x, normal.y, normal.z);
outColor
=
vec4
(
result
,
1
.
0
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/App.cpp
+
9
−
14
View file @
9cf4035b
...
@@ -181,7 +181,7 @@ void App::MoveCamera()
...
@@ -181,7 +181,7 @@ void App::MoveCamera()
}
}
if
(
mouseScrollEvent
)
if
(
mouseScrollEvent
)
{
{
c
.
zoom
(
mouseScrollOffset
.
y
*
0.
2
,
normalizedmouse
[
0
],
normalizedmouse
[
1
]);
c
.
zoom
(
mouseScrollOffset
.
y
*
0.
8
,
normalizedmouse
[
0
],
normalizedmouse
[
1
]);
mouseScrollEvent
=
false
;
mouseScrollEvent
=
false
;
}
}
}
}
...
@@ -191,18 +191,19 @@ void App::MoveCamera()
...
@@ -191,18 +191,19 @@ void App::MoveCamera()
void
App
::
Render
()
void
App
::
Render
()
{
{
//
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
std
::
chrono
::
steady_clock
::
time_point
begin
=
std
::
chrono
::
steady_clock
::
now
();
GetInput
();
GetInput
();
MoveCamera
();
MoveCamera
();
v
->
SetCameraTransform
(
c
.
transform
());
v
->
SetCameraTransform
(
c
.
transform
());
v
->
Render
();
v
->
Render
();
RenderUI
(
v
->
GetTexture
());
RenderUI
(
v
->
GetTexture
());
// std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
// std::this_thread::sleep_for(std::chrono::microseconds(17 * 1000) - std::chrono::microseconds(std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()));
glfwSwapBuffers
(
window
);
glfwSwapBuffers
(
window
);
glfwPollEvents
();
glfwPollEvents
();
if
(
/*glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS || */
glfwWindowShouldClose
(
window
))
if
(
/*glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS || */
glfwWindowShouldClose
(
window
))
ShouldClose
=
true
;
ShouldClose
=
true
;
std
::
chrono
::
steady_clock
::
time_point
end
=
std
::
chrono
::
steady_clock
::
now
();
frametime
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
end
-
begin
).
count
();
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
microseconds
(
17
*
1000
)
-
std
::
chrono
::
microseconds
(
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
end
-
begin
).
count
()));
}
}
void
App
::
RenderUI
(
unsigned
int
FBOtexture
)
void
App
::
RenderUI
(
unsigned
int
FBOtexture
)
...
@@ -215,7 +216,7 @@ void App::RenderUI(unsigned int FBOtexture)
...
@@ -215,7 +216,7 @@ void App::RenderUI(unsigned int FBOtexture)
ImGui
::
NewFrame
();
ImGui
::
NewFrame
();
ImGui
::
DockSpaceOverViewport
();
ImGui
::
DockSpaceOverViewport
();
//ImGui::ShowDemoWindow();
//
ImGui::ShowDemoWindow();
{
{
static
int
counter
=
0
;
static
int
counter
=
0
;
...
@@ -243,7 +244,7 @@ void App::RenderUI(unsigned int FBOtexture)
...
@@ -243,7 +244,7 @@ void App::RenderUI(unsigned int FBOtexture)
v
->
SetLightPos
(
lightPos
);
v
->
SetLightPos
(
lightPos
);
ImGui
::
Text
(
"Ctrl + click on the sliders for text input"
);
ImGui
::
Text
(
"Ctrl + click on the sliders for text input"
);
ImGui
::
Text
(
"Grid unit: %fmm"
,
scale
);
ImGui
::
Text
(
"Grid unit: %
.2
fmm"
,
scale
);
ImGui
::
SliderFloat
(
"Scale"
,
&
scale
,
0.0
f
,
10.0
f
);
ImGui
::
SliderFloat
(
"Scale"
,
&
scale
,
0.0
f
,
10.0
f
);
ImGui
::
SliderFloat
(
"Model x"
,
&
x
,
-
10.0
f
,
10.0
f
);
ImGui
::
SliderFloat
(
"Model x"
,
&
x
,
-
10.0
f
,
10.0
f
);
ImGui
::
SliderFloat
(
"Model y"
,
&
y
,
-
10.0
f
,
10.0
f
);
ImGui
::
SliderFloat
(
"Model y"
,
&
y
,
-
10.0
f
,
10.0
f
);
...
@@ -259,21 +260,15 @@ void App::RenderUI(unsigned int FBOtexture)
...
@@ -259,21 +260,15 @@ void App::RenderUI(unsigned int FBOtexture)
if
(
ImGui
::
Button
(
"Toggle wireframe mode"
))
if
(
ImGui
::
Button
(
"Toggle wireframe mode"
))
v
->
ToggleWireframe
();
v
->
ToggleWireframe
();
}
}
ImGui
::
Text
(
"Application average %.3f ms/frame"
,
frametime
/
1000.0
f
);
ImGui
::
Text
(
"Application average %.3f ms/frame (%.1f FPS)"
,
1000.0
f
/
ImGui
::
GetIO
().
Framerate
,
ImGui
::
GetIO
().
Framerate
);
ImGui
::
End
();
ImGui
::
End
();
}
}
{
{
ImGui
::
Begin
(
"Viewport"
);
ImGui
::
Begin
(
"Viewport"
);
mouseIsOverViewport
=
ImGui
::
IsWindowHovered
();
mouseIsOverViewport
=
ImGui
::
IsWindowHovered
();
v
->
SetSize
(
ImGui
::
GetWindowSize
());
v
->
SetPos
(
ImGui
::
GetWindowPos
());
v
->
SetPos
(
ImGui
::
GetWindowPos
());
v
->
SetSize
({
v
->
GetSize
().
x
-
16
,
v
->
GetSize
().
y
-
(
ImGui
::
GetFontSize
()
+
22
)});
v
->
SetSize
(
ImGui
::
GetContentRegionAvail
());
/*
22 = 3 * 2 Title bar FramePadding (+ font size to get title bar height) https://github.com/ocornut/imgui/issues/1539
+ 8 * 2 Top and bottom internal window padding
*/
ImGui
::
GetWindowDrawList
()
->
AddImage
(
ImGui
::
GetWindowDrawList
()
->
AddImage
(
(
void
*
)(
intptr_t
)
FBOtexture
,
(
void
*
)(
intptr_t
)
FBOtexture
,
ImVec2
(
ImGui
::
GetCursorScreenPos
()),
ImVec2
(
ImGui
::
GetCursorScreenPos
()),
...
...
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