summaryrefslogtreecommitdiff
path: root/src/example
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-12-05 09:21:26 +0800
committerchai <chaifix@163.com>2019-12-05 09:21:26 +0800
commit8e684dc0c76708e3174f005aebcaabc144b85500 (patch)
treed7803e49ee1fdb5575128114d19499787f870c00 /src/example
parent2e82e2ddd0852b8063a3d6645366f53ee844e273 (diff)
*背面剔除
Diffstat (limited to 'src/example')
-rw-r--r--src/example/example_texture.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/src/example/example_texture.c b/src/example/example_texture.c
index 5411a12..db2868b 100644
--- a/src/example/example_texture.c
+++ b/src/example/example_texture.c
@@ -16,43 +16,31 @@ int face[] = {
0, 1, 2, 0, 2, 3,
1, 5, 2, 2, 5, 6,
4, 6, 5, 4, 7, 6,
- 0, 7, 4, 0, 3, 7,
+ 0, 3, 7, 0, 7, 4,
0, 4, 1, 1, 4, 5,
2, 6, 3, 3, 6, 7
};
-static Mat4 m;
-
void vert(UniformCollection* uniforms, VertexShaderIn* in, Vec4* homocoord) {
static Vec4 p; p.xyz = *in->vertex->position; p.w = 1;
mat4_applytovec4(uniforms->mvp, &p, homocoord);
}
bool frag(UniformCollection* uniforms, FragmentShaderIn* in, Color* color) {
ssrS_bcpcolor(in->bc, in->A->color, in->B->color, in->C->color, color);
- //ssrum4(1);
- //Vec2 uv;
- //ssrS_bcpvec2(in->bc, in->A->uv, in->B->uv, in->C->uv, &uv);
- //int x = uv.x * 10;
- //int y = uv.y * 10;
- //if (x % 2 && y % 2) {
- // *color = 0xffffffff;
- //} else {
- // *color = 0xff111111;
- //}
- return 0;
+ return 1;
}
Program program = { vert, frag };
void onloadtexture(void* data) {
ssr_matrixmode(MATRIX_PROJECTION);
ssr_loadidentity();
- ssr_perspective(100, 1.25f, 0.1f, 10);
+ ssr_perspective(90, 1.25f, 0.1f, 10);
+ //ssr_ortho(-5, 5, -4, 4, 0.1, 10);
ssr_matrixmode(MATRIX_VIEW);
ssr_loadidentity();
- //Vec3 pos = { 0,0,0 }, target = { 0,0,-1 }, up = { 0,1,0 };
- //ssr_lookat(&pos, &target, &up);
+ Vec3 p = { 0, 0, 0 }, target = { 0, 0, -1 };
+ ssr_lookat(&p, &target, &vec3up);
- /*ö*/
quad = ssrM_newvector(Vert*, 8);
quad[0] = vert_new(VERTMASK_POSITION | VERTMASK_COLOR);
quad[1] = vert_new(VERTMASK_POSITION | VERTMASK_COLOR);
@@ -62,14 +50,14 @@ void onloadtexture(void* data) {
quad[5] = vert_new(VERTMASK_POSITION | VERTMASK_COLOR);
quad[6] = vert_new(VERTMASK_POSITION | VERTMASK_COLOR);
quad[7] = vert_new(VERTMASK_POSITION | VERTMASK_COLOR);
- *quad[0]->position = verts[0]; quad[0]->color = colors[0]; quad[0]->index = 0;
- *quad[1]->position = verts[1]; quad[1]->color = colors[1]; quad[1]->index = 1;
- *quad[2]->position = verts[2]; quad[2]->color = colors[2]; quad[2]->index = 2;
- *quad[3]->position = verts[3]; quad[3]->color = colors[3]; quad[3]->index = 3;
- *quad[4]->position = verts[4]; quad[4]->color = colors[4]; quad[4]->index = 4;
- *quad[5]->position = verts[5]; quad[5]->color = colors[5]; quad[5]->index = 5;
- *quad[6]->position = verts[6]; quad[6]->color = colors[6]; quad[6]->index = 6;
- *quad[7]->position = verts[7]; quad[7]->color = colors[7]; quad[7]->index = 7;
+ quad[0]->index = 0; *quad[0]->position = verts[0]; quad[0]->color = colors[0];
+ quad[1]->index = 1; *quad[1]->position = verts[1]; quad[1]->color = colors[1];
+ quad[2]->index = 2; *quad[2]->position = verts[2]; quad[2]->color = colors[2];
+ quad[3]->index = 3; *quad[3]->position = verts[3]; quad[3]->color = colors[3];
+ quad[4]->index = 4; *quad[4]->position = verts[4]; quad[4]->color = colors[4];
+ quad[5]->index = 5; *quad[5]->position = verts[5]; quad[5]->color = colors[5];
+ quad[6]->index = 6; *quad[6]->position = verts[6]; quad[6]->color = colors[6];
+ quad[7]->index = 7; *quad[7]->position = verts[7]; quad[7]->color = colors[7];
ssr_bindvertices(quad, 8, face, 12);
@@ -89,8 +77,7 @@ void onupdatetexture(void*data) {
ssr_matrixmode(MATRIX_MODEL);
ssr_loadidentity();
ssr_translate(0, 0, -3);
-// ssr_rotate(-30, 1, 1, 0);
- ssr_rotate(360 * sin(_t += dt/5000.f), 1, 1, 0);
+ ssr_rotate(_t -= dt / 50.f, 1, 1, 1);
}
void ondrawtexture(void*data) {