Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Graphics
pew
Commits
cb5230bc
Commit
cb5230bc
authored
2 years ago
by
Evy Storozhenko
Browse files
Options
Downloads
Patches
Plain Diff
made rendering loop
parent
7ac1274e
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
src/pew/main.cpp
+13
-14
13 additions, 14 deletions
src/pew/main.cpp
src/pew/scene/scene.cpp
+20
-6
20 additions, 6 deletions
src/pew/scene/scene.cpp
src/pew/scene/scene.hpp
+20
-1
20 additions, 1 deletion
src/pew/scene/scene.hpp
with
53 additions
and
21 deletions
src/pew/main.cpp
+
13
−
14
View file @
cb5230bc
...
...
@@ -99,21 +99,20 @@ vikingScene(Scene& scene) {
int
main
()
{
constexpr
auto
aspect
=
16.0
/
9.0
;
constexpr
auto
width
=
192
0
;
constexpr
auto
width
=
30
0
;
constexpr
auto
height
=
static_cast
<
int
>
(
width
/
aspect
);
constexpr
auto
lookFrom
=
vec3
(
0
,
2
,
1
);
constexpr
auto
lookAt
=
vec3
(
0
,
1
,
-
1
);
constexpr
auto
lookFrom
=
vec3
(
13
,
2
,
3
);
constexpr
auto
lookAt
=
vec3
(
0
,
0
,
0
);
Scene
scene
{
{
width
,
height
}
};
// scene.getRenderPass().setMaxDepth(50).setSampleRate(100).setCamera<DepthCamera>(
// lookFrom, lookAt, vec3(0, 1, 0), 70, aspect, 0.1, (lookAt - lookFrom).length());
scene
.
getRenderPass
().
setMaxDepth
(
50
).
setSampleRate
(
100
).
setCamera
<
HitCamera
>
(
lookFrom
,
lookAt
,
vec3
(
0
,
1
,
0
),
70.0
,
aspect
);
// populateScene(scene);
triangleScene
(
scene
);
vikingScene
(
scene
);
scene
.
render
(
20
,
true
,
true
);
scene
.
waitIdle
();
scene
.
getRenderPass
().
setMaxDepth
(
50
).
setSampleRate
(
10
).
setCamera
<
HitCamera
>
(
lookFrom
,
lookAt
,
vec3
(
0
,
1
,
0
),
20.0
,
aspect
);
while
(
!
scene
.
shouldClose
())
{
scene
.
clear
();
populateScene
(
scene
);
scene
.
render
(
8
,
false
,
true
);
scene
.
waitIdle
<
false
>
();
}
scene
.
closeWindow
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/pew/scene/scene.cpp
+
20
−
6
View file @
cb5230bc
...
...
@@ -13,28 +13,42 @@ namespace pew {
str
<<
"Rendering at "
<<
extent
.
width
<<
"x"
<<
extent
.
height
;
window
.
setTitle
(
str
.
str
());
}
void
Scene
::
render
(
uint32_t
threadCount
,
bool
detectEdges
,
bool
showWindow
)
{
if
(
showWindow
)
window
.
startAndFork
();
static
std
::
thread
*
window_thread
=
showWindow
?
window
.
startAndFork
()
:
nullptr
;
if
(
detectEdges
)
{
renderPass
.
renderHitStage
(
threadCount
)
->
join
();
hitBufferAsColor
=
renderPass
.
hitBufferAsColor
();
window
.
addBuffer
(
&
hitBufferAsColor
);
static
bool
isBufferAdded
=
false
;
if
(
!
isBufferAdded
)
{
hitBufferAsColor
=
renderPass
.
hitBufferAsColor
();
window
.
addBuffer
(
&
hitBufferAsColor
);
isBufferAdded
=
true
;
}
}
job
=
renderPass
.
renderColorStage
(
threadCount
,
detectEdges
,
true
);
}
void
Scene
::
waitIdle
()
{
if
(
job
)
job
->
join
();
window
.
join
();
Scene
::
clear
()
{
collection
.
collection
.
clear
();
materials
.
clear
();
textures
.
clear
();
}
void
Scene
::
onShouldClose
()
{
m_shouldClose
=
true
;
}
void
Scene
::
closeWindow
()
{
window
.
closeWindow
();
if
(
job
)
job
->
stop
();
}
void
Scene
::
onKeyInput
(
SDL_KeyboardEvent
event
,
bool
down
)
{
if
(
down
)
{
...
...
This diff is collapsed.
Click to expand it.
src/pew/scene/scene.hpp
+
20
−
1
View file @
cb5230bc
...
...
@@ -26,6 +26,7 @@ namespace pew {
Window
window
;
std
::
shared_ptr
<
RenderJob
>
job
;
std
::
vector
<
Color
>
hitBufferAsColor
;
bool
m_shouldClose
=
false
;
public:
Scene
(
const
Extent2D
&
extent
);
...
...
@@ -33,8 +34,15 @@ namespace pew {
void
render
(
uint32_t
threadCount
,
bool
detectEdges
,
bool
showWindow
);
template
<
bool
CLOSE_ON_FINISH
>
void
waitIdle
();
waitIdle
()
{
if
(
job
)
job
->
join
();
if
constexpr
(
CLOSE_ON_FINISH
)
{
closeWindow
();
window
.
join
();
}
}
private
:
void
...
...
@@ -44,6 +52,9 @@ namespace pew {
onKeyInput
(
SDL_KeyboardEvent
event
,
bool
down
);
public
:
void
closeWindow
();
template
<
typename
T
,
typename
...
Args
>
auto
&
add
(
Args
&&
...
args
)
{
...
...
@@ -69,6 +80,9 @@ namespace pew {
renderPass
.
setCamera
<
T
>
(
std
::
forward
<
Args
>
(
args
)...);
}
void
clear
();
inline
auto
&
getRenderPass
()
{
return
renderPass
;
...
...
@@ -78,6 +92,11 @@ namespace pew {
getWindow
()
{
return
window
;
}
inline
auto
shouldClose
()
{
return
m_shouldClose
;
}
};
}
// namespace pew
...
...
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