-
Notifications
You must be signed in to change notification settings - Fork 0
/
gles1Glue.c
66 lines (52 loc) · 1.26 KB
/
gles1Glue.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
58
59
60
61
62
63
64
65
66
/*
* glesGlue.c
* MultiTouchScreenDemo
*
* Created by David Petrie on 6/11/10.
* Copyright 2010 n/a. All rights reserved.
*
*/
#include "gles1Glue.h"
#define kVertexCount 8192
static gVertex_t vertices[kVertexCount];
static gVertex_t vertex;
static GLenum currentPrimitive = GL_TRIANGLES;
static uint32_t vertexCount = 0;
void gGlBegin(GLenum prim)
{
currentPrimitive = prim;
vertexCount = 0;
glVertexPointer(3, GL_FLOAT, sizeof(gVertex_t), vertices[0].xyz);
glTexCoordPointer(2, GL_FLOAT, sizeof(gVertex_t), vertices[0].st);
glColorPointer(4, GL_FLOAT, sizeof(gVertex_t), vertices[0].rgba);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
}
void gGlVertex3f(float x, float y, float z)
{
if (vertexCount > kVertexCount) return;
vec3Set(vertex.xyz, x, y, z);
vertices[vertexCount] = vertex;
vertexCount++;
}
void gGlColor4f(float r, float g, float b, float a)
{
color4Set(vertex.rgba, r, g, b, a);
}
void gGlTexCoord2f(float s, float t)
{
vec2Set(vertex.st, s, t);
}
void gGlEnd()
{
if (vertexCount == 0)
{
currentPrimitive = 0;
return;
}
glDrawArrays(currentPrimitive, 0, vertexCount);
vertexCount = 0;
currentPrimitive = 0;
}
void gGlError(const char *source) {}