Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
uva
Commits
6f811dc5
Commit
6f811dc5
authored
Nov 29, 2010
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Graphics assignment 10: texture mapping
Added some finishing changes and comments.
parent
9fecafab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
graphics/ass10/geometry.c
graphics/ass10/geometry.c
+4
-1
graphics/ass10/main.c
graphics/ass10/main.c
+15
-10
No files found.
graphics/ass10/geometry.c
View file @
6f811dc5
...
...
@@ -99,7 +99,10 @@ setHemispherePoint(vec3 *p, vec3* n, vec3* t, int latitude, int longitude,
p
->
y
=
oy
+
sin
(
latitude
*
dToR
)
*
s
;
p
->
z
=
oz
+
cos
(
longitude
*
dToR
)
*
cos
(
latitude
*
dToR
)
*
s
;
// Set texture coordinate
// Set texture coordinate, use the longitude to determine the vertical
// component and the latitude for vertical. Because the texture image
// is four times as wide as it is high, divide the latitude by 90 and
// the longitude by 360).
t
->
x
=
longitude
/
360
.
0
;
t
->
y
=
latitude
/
90
.
0
;
...
...
graphics/ass10/main.c
View file @
6f811dc5
...
...
@@ -128,7 +128,7 @@ InitializePolygonlists(void)
loadPolygonalObject
(
polylistHouse
,
"house.obj"
,
texture_names
,
1
.
0
,
object_positions
[
0
].
x
,
object_positions
[
0
].
y
,
object_positions
[
0
].
z
);
// A single tree object
// A single tree object
, use the banana_leaf object for a single leaf
polylistTreeLeafs
=
CreatePolylist
(
4
);
loadPolygonalObject
(
polylistTreeLeafs
,
"banana_leaf.obj"
,
texture_names
,
1
.
0
,
0
,
1
.
8
,
0
);
...
...
@@ -256,14 +256,18 @@ InitGL(void)
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_REPEAT
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_REPEAT
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
// Set mip-mapping type
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR_MIPMAP_LINEAR
);
glCheckError
(
"glTexParameteri"
);
// Enable mip-mapping
gluBuild2DMipmaps
(
GL_TEXTURE_2D
,
texture_internal_format
,
width
,
height
,
texture_format
,
texture_type
,
image_data
);
glCheckError
(
"ggluBuild2DMipmaps"
);
//glTexImage2D(GL_TEXTURE_2D, 0, texture_internal_format,
// width, height, 0, texture_format, texture_type, image_data);
glCheckError
(
"glTexImage2D"
);
//
glCheckError("glTexImage2D");
// Free the image data, as OpenGL will have made its internal copy by now
free
(
image_data
);
...
...
@@ -420,15 +424,16 @@ DrawGLScene(void)
DrawPolylist
(
polylistTreeStem
);
// Draw 5 to 10 leafs
for
(
int
l
=
0
,
step
=
360
/
(
5
+
rand
()
%
6
);
l
<
360
;
l
+=
step
)
// Draw 5 to 10 leafs, rotate them according to the number of leafs
int
i
=
0
,
n
=
5
+
rand
()
%
6
;
float
step
=
360
.
0
/
n
;
while
(
i
++
<
n
)
{
glPushMatrix
();
if
(
i
)
glRotatef
(
step
,
0
,
1
,
0
);
glRotatef
((
float
)
l
,
0
,
1
,
0
);
DrawPolylist
(
polylistTreeLeafs
);
glPopMatrix
();
}
glPopMatrix
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment