Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
ProjectiveTextureMapping
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
Container registry
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WooHyungChoi
ProjectiveTextureMapping
Commits
363fa20d
Commit
363fa20d
authored
5 years ago
by
Woohyung Choi
Browse files
Options
Downloads
Patches
Plain Diff
projective mapping 적용중
parent
3cdddf08
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
LearnOpenGL/OpenGLWrapper.cpp
+33
-0
33 additions, 0 deletions
LearnOpenGL/OpenGLWrapper.cpp
LearnOpenGL/OpenGLWrapper.h
+1
-0
1 addition, 0 deletions
LearnOpenGL/OpenGLWrapper.h
LearnOpenGL/Source.cpp
+13
-2
13 additions, 2 deletions
LearnOpenGL/Source.cpp
with
47 additions
and
2 deletions
LearnOpenGL/OpenGLWrapper.cpp
+
33
−
0
View file @
363fa20d
...
...
@@ -175,6 +175,39 @@ void RenderObject::render(Camera &camera)
glUseProgram
(
0
);
}
void
RenderObject
::
projective_render
(
Camera
&
camera
)
{
const
glm
::
mat4
bias
=
{
0.5
,
0.0
,
0.0
,
0.5
,
0.0
,
0.5
,
0.0
,
0.5
,
0.0
,
0.0
,
0.5
,
0.5
,
0.0
,
0.0
,
0.0
,
1.0
};
glm
::
mat4
pp
=
glm
::
perspective
(
glm
::
radians
(
camera
.
Zoom
),
(
float
)
_SCR_WIDTH
/
(
float
)
_SCR_HEIGHT
,
0.1
f
,
10.0
f
);
glm
::
mat4
pv
=
glm
::
lookAt
(
camera
.
Position
,
camera
.
Position
+
camera
.
Front
,
camera
.
Up
);
glm
::
mat4
InvView
=
glm
::
inverse
(
camera
.
GetViewMatrix
());
glm
::
mat4
result
=
bias
*
pp
*
pv
;
auto
prog
=
material
->
get_program
();
glUseProgram
(
prog
);
glm
::
mat4
projection
=
glm
::
perspective
(
glm
::
radians
(
camera
.
Zoom
),
(
float
)
_SCR_WIDTH
/
(
float
)
_SCR_HEIGHT
,
0.1
f
,
500.0
f
);
glm
::
mat4
view
=
camera
.
GetViewMatrix
();
set_uniform_value
(
prog
,
"TexGenMatCam0"
,
result
);
set_uniform_value
(
prog
,
"projection"
,
projection
);
set_uniform_value
(
prog
,
"view"
,
view
);
set_uniform_value
(
prog
,
"model"
,
model
);
{
glActiveTexture
(
GL_TEXTURE0
);
glBindTexture
(
GL_TEXTURE_2D
,
material
->
get_diffuseMap
());
}
{
glActiveTexture
(
GL_TEXTURE1
);
glBindTexture
(
GL_TEXTURE_2D
,
material
->
get_specularMap
());
}
draw_mesh
(
*
mesh
);
glUseProgram
(
0
);
}
RenderObject
*
make_render_object
(
Mesh
*
mesh
)
{
RenderObject
*
ro
=
new
RenderObject
(
mesh
);
...
...
This diff is collapsed.
Click to expand it.
LearnOpenGL/OpenGLWrapper.h
+
1
−
0
View file @
363fa20d
...
...
@@ -77,6 +77,7 @@ public:
void
set_material
(
Material
*
_material
);
void
render
(
Camera
&
camera
);
void
projective_render
(
Camera
&
camera
);
};
RenderObject
*
make_render_object
(
Mesh
*
mesh
);
...
...
This diff is collapsed.
Click to expand it.
LearnOpenGL/Source.cpp
+
13
−
2
View file @
363fa20d
...
...
@@ -57,6 +57,7 @@ int main()
auto
lamp
=
build_program
(
"Lighting_Lamp"
);
auto
lightmap
=
build_program
(
"Lighting_Maps"
);
auto
texture_shader
=
build_program
(
"Texture"
);
auto
projector_shader
=
build_program
(
"Projector"
);
auto
cube
=
make_mesh
(
"cube.obj"
);
...
...
@@ -66,12 +67,22 @@ int main()
auto
white
=
load_image
(
"white.png"
);
auto
transparent
=
load_image
(
"transparent.png"
);
auto
wall
=
load_image
(
"wall.jpg"
);
auto
container_diffuse
=
load_image
(
"container2.png"
);
auto
container_specular
=
load_image
(
"container2_specular.png"
);
auto
defaultMaterial
=
new
Material
(
lightmap
,
orange
,
transparent
);
auto
cubeMaterial
=
new
Material
(
lightmap
,
container_diffuse
,
container_specular
);
auto
planeMaterial
=
new
Material
(
lightmap
,
magenta
,
transparent
);
auto
projectorMaterial
=
new
Material
(
projector_shader
,
transparent
,
transparent
);
auto
projector
=
make_render_object
(
make_mesh
(
"cube.obj"
));
{
projector
->
set_translate
(
glm
::
vec3
(
0.0
f
,
10.0
f
,
0.0
f
));
}
{
projector
->
set_material
(
projectorMaterial
);
}
auto
teapot
=
make_render_object
(
make_mesh
(
"teapot.obj"
));
{
...
...
@@ -79,7 +90,7 @@ int main()
teapot
->
set_rotate
(
glm
::
vec3
(
-
90.0
f
,
0.0
f
,
0.0
f
));
}
{
teapot
->
set_material
(
default
Material
);
teapot
->
set_material
(
projector
Material
);
}
auto
cube1
=
make_render_object
(
cube
);
...
...
@@ -140,7 +151,7 @@ int main()
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
{
teapot
->
render
(
camera
);
teapot
->
projective_
render
(
camera
);
cube1
->
render
(
camera
);
cube2
->
render
(
camera
);
cube3
->
render
(
camera
);
...
...
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