-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecal.h
50 lines (40 loc) · 1.13 KB
/
decal.h
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
#ifndef DECAL_H
#define DECAL_H
#include <libdragon.h>
#include <GL/gl.h>
void draw_quad()
{
glBegin(GL_TRIANGLE_STRIP);
glNormal3f(0, 1, 0);
glTexCoord2f(0, 0);
glVertex3f(-0.5f, 0, -0.5f);
glTexCoord2f(0, 1);
glVertex3f(-0.5f, 0, 0.5f);
glTexCoord2f(1, 0);
glVertex3f(0.5f, 0, -0.5f);
glTexCoord2f(1, 1);
glVertex3f(0.5f, 0, 0.5f);
glEnd();
}
void render_decal()
{
rdpq_debug_log_msg("Decal");
glPushMatrix();
glTranslatef(0, 0, 6);
glRotatef(35, 0, 1, 0);
glScalef(3, 3, 3);
// Decals are drawn with the depth func set to GL_EQUAL. Note that glPolygonOffset is not supported on N64.
glDepthFunc(GL_EQUAL);
// Disable writing to depth buffer, because the depth value will be the same anyway
glDepthMask(GL_FALSE);
// Apply vertex color as material color.
// This time, we set one vertex color for the entire model.
glEnable(GL_COLOR_MATERIAL);
glColor4f(1.0f, 0.4f, 0.2f, 0.5f);
draw_quad();
glDisable(GL_COLOR_MATERIAL);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS);
glPopMatrix();
}
#endif