added glshim library
This commit is contained in:
27
project/jni/glshim/test/tests/array/skip.c
Normal file
27
project/jni/glshim/test/tests/array/skip.c
Normal file
@@ -0,0 +1,27 @@
|
||||
int main() {
|
||||
#define STRIDE 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
GLfloat vert[] = {
|
||||
0, 0, 0, STRIDE,
|
||||
1, 1, 1, STRIDE,
|
||||
2, 2, 2, STRIDE,
|
||||
3, 3, 3, STRIDE,
|
||||
4, 4, 4, STRIDE,
|
||||
5, 5, 5, STRIDE,
|
||||
};
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_FLOAT, 12 * sizeof(GLfloat), vert);
|
||||
glDrawArrays(GL_QUADS, 2, 4);
|
||||
|
||||
GLfloat vert_out[] = {
|
||||
2, 2, 2,
|
||||
3, 3, 3,
|
||||
4, 4, 4,
|
||||
5, 5, 5,
|
||||
};
|
||||
GLushort indices[] = {0, 1, 3, 1, 2, 3};
|
||||
test_glEnableClientState(GL_VERTEX_ARRAY);
|
||||
test_glVertexPointer(3, GL_FLOAT, 12 * 4, vert);
|
||||
test_glVertexPointer(3, GL_FLOAT, 0, vert_out);
|
||||
test_glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
mock_return;
|
||||
}
|
||||
52
project/jni/glshim/test/tests/block/quads.c
Normal file
52
project/jni/glshim/test/tests/block/quads.c
Normal file
@@ -0,0 +1,52 @@
|
||||
int main() {
|
||||
glBegin(GL_QUADS);
|
||||
glColor4f(0, 0.1, 0.2, 0.3);
|
||||
glTexCoord2f(0.4, 0.5);
|
||||
glVertex3f(0, 1, 2);
|
||||
glVertex3f(3, 4, 5);
|
||||
glVertex3f(6, 7, 8);
|
||||
glVertex3f(9, 10, 11);
|
||||
glEnd();
|
||||
|
||||
GLfloat verts[] = {
|
||||
0, 1, 2,
|
||||
3, 4, 5,
|
||||
6, 7, 8,
|
||||
9, 10, 11,
|
||||
};
|
||||
|
||||
GLfloat color[] = {
|
||||
0, 0.1, 0.2, 0.3,
|
||||
0, 0.1, 0.2, 0.3,
|
||||
0, 0.1, 0.2, 0.3,
|
||||
0, 0.1, 0.2, 0.3,
|
||||
};
|
||||
|
||||
GLfloat tex[] = {
|
||||
0.4, 0.5,
|
||||
0.4, 0.5,
|
||||
0.4, 0.5,
|
||||
0.4, 0.5,
|
||||
};
|
||||
|
||||
GLushort indices[] = {
|
||||
0, 1, 3,
|
||||
1, 2, 3,
|
||||
};
|
||||
|
||||
// TODO: out of order glEnableClientState?
|
||||
test_glColor4f(0.0, 0.1, 0.2, 0.3);
|
||||
|
||||
test_glEnableClientState(GL_VERTEX_ARRAY);
|
||||
test_glVertexPointer(3, GL_FLOAT, 0, verts);
|
||||
test_glEnableClientState(GL_COLOR_ARRAY);
|
||||
test_glColorPointer(4, GL_FLOAT, 0, color);
|
||||
test_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
test_glTexCoordPointer(2, GL_FLOAT, 0, tex);
|
||||
test_glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
|
||||
test_glDisableClientState(GL_VERTEX_ARRAY);
|
||||
test_glDisableClientState(GL_COLOR_ARRAY);
|
||||
test_glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
mock_return;
|
||||
}
|
||||
18
project/jni/glshim/test/tests/block/rect.c
Normal file
18
project/jni/glshim/test/tests/block/rect.c
Normal file
@@ -0,0 +1,18 @@
|
||||
int main() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
glRectf(0, 0, 1, 1);
|
||||
|
||||
test_glEnableClientState(GL_VERTEX_ARRAY);
|
||||
// TODO: pointers are skipped in verification
|
||||
GLfloat verts[] = {
|
||||
0, 0, 0,
|
||||
1, 0, 0,
|
||||
1, 1, 0,
|
||||
0, 1, 0,
|
||||
};
|
||||
test_glVertexPointer(3, GL_FLOAT, 0, verts);
|
||||
test_glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
test_glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
mock_return;
|
||||
}
|
||||
18
project/jni/glshim/test/tests/block/tri.c
Normal file
18
project/jni/glshim/test/tests/block/tri.c
Normal file
@@ -0,0 +1,18 @@
|
||||
int main() {
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f(0, 1, 2);
|
||||
glVertex3f(3, 4, 5);
|
||||
glVertex3f(6, 7, 8);
|
||||
glEnd();
|
||||
|
||||
test_glEnableClientState(GL_VERTEX_ARRAY);
|
||||
GLfloat verts[] = {
|
||||
0, 1, 2,
|
||||
3, 4, 5,
|
||||
6, 7, 8,
|
||||
};
|
||||
test_glVertexPointer(3, GL_FLOAT, 0, verts);
|
||||
test_glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
test_glDisableClientState(GL_VERTEX_ARRAY);
|
||||
mock_return;
|
||||
}
|
||||
30
project/jni/glshim/test/tests/list/nested.c
Normal file
30
project/jni/glshim/test/tests/list/nested.c
Normal file
@@ -0,0 +1,30 @@
|
||||
int main() {
|
||||
GLuint list = glGenLists(3);
|
||||
glNewList(list, GL_COMPILE);
|
||||
glRectf(0, 0, 1, 1);
|
||||
glEndList();
|
||||
|
||||
glNewList(list + 1, GL_COMPILE);
|
||||
glCallList(list);
|
||||
glEndList();
|
||||
|
||||
glNewList(list + 2, GL_COMPILE);
|
||||
glCallList(list + 1);
|
||||
glEndList();
|
||||
|
||||
glCallList(list + 2);
|
||||
|
||||
GLfloat verts[] = {
|
||||
0, 0, 0,
|
||||
1, 0, 0,
|
||||
1, 1, 0,
|
||||
0, 1, 0,
|
||||
};
|
||||
|
||||
test_glEnableClientState(GL_VERTEX_ARRAY);
|
||||
test_glVertexPointer(3, GL_FLOAT, 0, verts);
|
||||
test_glDrawArrays(6, 0, 4);
|
||||
test_glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
mock_return;
|
||||
}
|
||||
6
project/jni/glshim/test/tests/list/new.c
Normal file
6
project/jni/glshim/test/tests/list/new.c
Normal file
@@ -0,0 +1,6 @@
|
||||
int main() {
|
||||
int list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
mock_assert(state.list.active, "glNewList failed\n");
|
||||
mock_return;
|
||||
}
|
||||
20
project/jni/glshim/test/tests/meta/test.py
Normal file
20
project/jni/glshim/test/tests/meta/test.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def walk(base):
|
||||
for root, _, files in os.walk(base):
|
||||
for name in files:
|
||||
yield os.path.join(root, name)
|
||||
|
||||
if __name__ == '__main__':
|
||||
failed = False
|
||||
for name in walk('tests'):
|
||||
if name.endswith('.c'):
|
||||
with open(name, 'r') as f:
|
||||
data = f.read()
|
||||
if not 'mock_return;' in data:
|
||||
print 'ERROR: "{}" has no mock_return;'.format(name)
|
||||
failed = True
|
||||
|
||||
if failed:
|
||||
sys.exit(1)
|
||||
35
project/jni/glshim/test/tests/render/feedback.c
Normal file
35
project/jni/glshim/test/tests/render/feedback.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "tack.h"
|
||||
|
||||
int main() {
|
||||
GLfloat buffer[4096];
|
||||
glFeedbackBuffer(4096, GL_2D, buffer);
|
||||
glRenderMode(GL_FEEDBACK);
|
||||
|
||||
glPassThrough(7);
|
||||
glRectf(0, 0, 1, 1);
|
||||
|
||||
int size = glRenderMode(GL_RENDER);
|
||||
assert(size == 15);
|
||||
|
||||
GLfloat *pos = buffer;
|
||||
#define _(val) assert(*pos++ == val)
|
||||
_(GL_PASS_THROUGH_TOKEN);
|
||||
_(7.0f);
|
||||
_(GL_POLYGON_TOKEN);
|
||||
_(3.0f);
|
||||
_(1.0f);
|
||||
_(0.0f);
|
||||
_(1.0f);
|
||||
_(1.0f);
|
||||
_(0.0f);
|
||||
_(0.0f);
|
||||
_(GL_POLYGON_TOKEN);
|
||||
_(3.0f);
|
||||
_(1.0f);
|
||||
_(1.0f);
|
||||
_(0.0f);
|
||||
_(1.0f);
|
||||
_(0.0f);
|
||||
_(0.0f);
|
||||
mock_return;
|
||||
}
|
||||
17
project/jni/glshim/test/tests/state/default.c
Normal file
17
project/jni/glshim/test/tests/state/default.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#define check(name, ...) { \
|
||||
GLfloat tmp[] = __VA_ARGS__; \
|
||||
assert(memcmp(state.name, tmp, sizeof(tmp)) == 0);}
|
||||
|
||||
int main() {
|
||||
check(current.color, {1.0f, 1.0f, 1.0f, 1.0f});
|
||||
check(current.normal, {0.0f, 0.0f, 1.0f});
|
||||
for (int i = 0; i < MAX_TEX; i++) {
|
||||
check(current.tex[i], {0, 0});
|
||||
texgen_state_t *t = &state.texgen[i];
|
||||
assert(t->R == GL_EYE_LINEAR);
|
||||
assert(t->Q == GL_EYE_LINEAR);
|
||||
assert(t->S == GL_EYE_LINEAR);
|
||||
assert(t->T == GL_EYE_LINEAR);
|
||||
}
|
||||
mock_return;
|
||||
}
|
||||
10
project/jni/glshim/test/tests/util/gl_str.c
Normal file
10
project/jni/glshim/test/tests/util/gl_str.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "gl_str.h"
|
||||
|
||||
int main() {
|
||||
#define check(func, name) assert(strcmp(func(name), #name) == 0);
|
||||
check(gl_str_primitive, GL_QUADS);
|
||||
check(gl_str, GL_FLOAT);
|
||||
check(gl_bits_glPushClientAttrib, GL_CLIENT_ALL_ATTRIB_BITS);
|
||||
check(gl_bits_glPushAttrib, GL_CURRENT_BIT | GL_POINT_BIT);
|
||||
mock_return;
|
||||
}
|
||||
30
project/jni/glshim/test/tests/util/tack.c
Normal file
30
project/jni/glshim/test/tests/util/tack.c
Normal file
@@ -0,0 +1,30 @@
|
||||
int main() {
|
||||
tack_t stack = {0};
|
||||
tack_push(&stack, 1);
|
||||
assert(tack_peek(&stack) == 1);
|
||||
assert(tack_len(&stack) == 1);
|
||||
|
||||
tack_push(&stack, 2);
|
||||
tack_push(&stack, 3);
|
||||
assert(tack_get(&stack, 0) == 1);
|
||||
assert(tack_peek(&stack) == 3);
|
||||
assert(tack_pop(&stack) == 3);
|
||||
assert(tack_peek(&stack) == 2);
|
||||
|
||||
tack_clear(&stack);
|
||||
assert(tack_len(&stack) == 0);
|
||||
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
tack_push(&stack, i);
|
||||
assert(tack_peek(&stack) == i);
|
||||
}
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
assert(tack_shift(&stack) == i);
|
||||
}
|
||||
|
||||
tack_clear(&stack);
|
||||
tack_set(&stack, 1, "test");
|
||||
assert(tack_get(&stack, 0) == NULL);
|
||||
assert(strcmp(tack_get(&stack, 1), "test") == 0);
|
||||
mock_return;
|
||||
}
|
||||
Reference in New Issue
Block a user