Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
6f811dc5
Commit
6f811dc5
authored
14 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Graphics assignment 10: texture mapping
Added some finishing changes and comments.
parent
9fecafab
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
graphics/ass10/geometry.c
+4
-1
4 additions, 1 deletion
graphics/ass10/geometry.c
graphics/ass10/main.c
+15
-10
15 additions, 10 deletions
graphics/ass10/main.c
with
19 additions
and
11 deletions
graphics/ass10/geometry.c
+
4
−
1
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
;
...
...
This diff is collapsed.
Click to expand it.
graphics/ass10/main.c
+
15
−
10
View file @
6f811dc5
...
...
@@ -128,9 +128,9 @@ 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
,
loadPolygonalObject
(
polylistTreeLeafs
,
"banana_leaf.obj"
,
texture_names
,
1
.
0
,
0
,
1
.
8
,
0
);
polylistTreeStem
=
CreatePolylist
(
10
);
...
...
@@ -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
();
glRotatef
((
float
)
l
,
0
,
1
,
0
);
if
(
i
)
glRotatef
(
step
,
0
,
1
,
0
);
DrawPolylist
(
polylistTreeLeafs
);
glPopMatrix
();
}
glPopMatrix
();
...
...
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