-
Notifications
You must be signed in to change notification settings - Fork 0
/
old-main.cpp
129 lines (87 loc) · 2.5 KB
/
old-main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "stdafx.h"
#include <stdlib.h>
// #include <windows.h>
#include <GL/glut.h>
#include "glm.h"
#include "Texture.h"
static float ypoz = 0, zpoz = 0;
GLMmodel* punteroM1 = NULL;
GLMmodel* punteroM2 = NULL;
GLuint texture;
Texture treeTextureAr[5];
bool LoadTreeTextures()
{
int i;
if (LoadTGA(&treeTextureAr[0], "modelos/felorcmale_Body.tga")) //&& LoadTGA(&treeTextureAr[1], "modelos/TEXTURA.tga"))
{
for (i = 0; i<1; i++){
glGenTextures(1, &treeTextureAr[i].texID);
glBindTexture(GL_TEXTURE_2D, treeTextureAr[i].texID);
glTexImage2D(GL_TEXTURE_2D, 0, treeTextureAr[i].bpp / 8, treeTextureAr[i].width, treeTextureAr[i].height, 0, treeTextureAr[i].type, GL_UNSIGNED_BYTE, treeTextureAr[i].imageData);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
if (treeTextureAr[i].imageData)
{
free(treeTextureAr[i].imageData);
}
}
return true;
}
else
{
return false;
}
}
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
LoadTreeTextures();
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
}
void graficar(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(3.0, 1.5, 2.0, 0.0, 0.0, 0.0, 0.0f, 1.0f, 0.0f);
glRotatef(ypoz, 0, 1, 0);
glTranslatef(0,-1,0);
glBindTexture(GL_TEXTURE_2D, treeTextureAr[0].texID);
glmDraw(punteroM1, GLM_SMOOTH | GLM_TEXTURE);
glTranslatef(1, 1, 1);
glBindTexture(GL_TEXTURE_2D, treeTextureAr[0].texID);
glmDraw(punteroM2, GLM_SMOOTH | GLM_TEXTURE);
glutSwapBuffers();
}
void redimensionar(int w, int h)
{
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (GLfloat)w / (GLfloat)h, 1.0, 500.0);
}
void animate(int i)
{
ypoz += 0.5;
if (ypoz>360) ypoz = 0;
glutPostRedisplay();
glutTimerFunc(2, animate, 1);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("JLPeralta");
init();
punteroM1 = glmReadOBJ("modelos/felorcmale.obj");
punteroM2 = glmReadOBJ("modelos/piernaDerecha.obj");
glutDisplayFunc(graficar);
glutReshapeFunc(redimensionar);
glutTimerFunc(2, animate, 1);
glutMainLoop();
return 0;
}