-
Notifications
You must be signed in to change notification settings - Fork 7
/
car.c
57 lines (47 loc) · 1.52 KB
/
car.c
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
#include"car.h"
extern float car_crash_angle=0.0;
Gbps_Car* CreateCar(GLuint* cartexture)
{
Gbps_Car* c=malloc(sizeof(Gbps_Car));
return c;
}
void RenderCar(Gbps_Car Car)
{
//
glEnable(GL_TEXTURE_2D);
glPushMatrix();//for the current car
glRotatef(car_crash_angle,1.0,0,0);
glTranslatef(Car.x,0.6,-Car.y);//car translate
glRotatef(-Car.rot,0,1,0);//car rotate
glBindTexture(GL_TEXTURE_2D, GBPS_texArr[GBPS_TEXTURE_CAR1]);
glmDraw(car1, GLM_SMOOTH | GLM_TEXTURE);
//tyredraw
glRotated(-90,0,1,0);//default import orientation at the moved position
glBindTexture(GL_TEXTURE_2D, GBPS_texArr[GBPS_TEXTURE_TYRE]);
glPushMatrix();//tl
glTranslatef(-1.205,-0.277,0.733);
glRotatef(-(Car.rot*2)+90,0,1,0);
glRotatef(Car.TyreRot,-1,0,0);
glmDraw(tyre1,GLM_SMOOTH | GLM_TEXTURE);
glPopMatrix();
glPushMatrix();//tr
glTranslatef(-1.206,-0.277,-0.731);
glRotatef(-(Car.rot*2)+270,0,1,0);
glRotatef(Car.TyreRot,1,0,0);
glmDraw(tyre1,GLM_SMOOTH | GLM_TEXTURE);
glPopMatrix();
glPushMatrix();//bl
glTranslatef(1.155,-0.277,0.731);
glRotatef(90,0,1,0);
glRotatef(Car.TyreRot,-1,0,0);
glmDraw(tyre1,GLM_SMOOTH | GLM_TEXTURE);
glPopMatrix();
glPushMatrix();//br
glTranslatef(1.154,-0.277,-0.733);
glRotatef(270,0,1,0);
glRotatef(Car.TyreRot,1,0,0);
glmDraw(tyre1,GLM_SMOOTH | GLM_TEXTURE);
glPopMatrix();
glDisable(GL_TEXTURE_2D);
glPopMatrix();
}