aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olv@lunarg.com>2015-04-22 14:56:17 +0800
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-04-30 17:09:34 -0600
commitae3b55d494ba4b5da191ec63587d70e675218e77 (patch)
tree24758f1791ae1442ff6fd4d0a288a730501de6fe
parentc7e4155dc5c350c559711b536790ac70d1ad92b1 (diff)
downloadusermoji-ae3b55d494ba4b5da191ec63587d70e675218e77.tar.xz
demos/cube: use GL conventions
Use GL conventions in vertex data and contents. Tranform to VK conventions in the vertex shader with gl_Position.y = -gl_Position.y;
-rw-r--r--demos/cube.c96
-rw-r--r--demos/cube.vert3
2 files changed, 42 insertions, 57 deletions
diff --git a/demos/cube.c b/demos/cube.c
index 7fd57f19..796a1400 100644
--- a/demos/cube.c
+++ b/demos/cube.c
@@ -130,111 +130,91 @@ struct VertexPosTex
#define UV(_u_, _v_) (_u_), (_v_), 0.f, 1.f
static const float g_vertex_buffer_data[] = {
- -1.0f,-1.0f,-1.0f, // Vertex 0
+ -1.0f,-1.0f,-1.0f, // -X side
-1.0f,-1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
-
- -1.0f, 1.0f, 1.0f, // Vertex 1
+ -1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
- -1.0f,-1.0f,-1.0f, // Vertex 2
+ -1.0f,-1.0f,-1.0f, // -Z side
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
-
- -1.0f,-1.0f,-1.0f, // Vertex 3
+ -1.0f,-1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
- -1.0f,-1.0f,-1.0f, // Vertex 4
+ -1.0f,-1.0f,-1.0f, // -Y side
1.0f,-1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-
- -1.0f,-1.0f,-1.0f, // Vertex 5
+ -1.0f,-1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
- -1.0f, 1.0f,-1.0f, // Vertex 6
+ -1.0f, 1.0f,-1.0f, // +Y side
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-
- -1.0f, 1.0f,-1.0f, // Vertex 7
+ -1.0f, 1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
- 1.0f, 1.0f,-1.0f, // Vertex 8
+ 1.0f, 1.0f,-1.0f, // +X side
1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
-
- 1.0f,-1.0f, 1.0f, // Vertex 9
+ 1.0f,-1.0f, 1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
- -1.0f, 1.0f, 1.0f, // Vertex 10
+ -1.0f, 1.0f, 1.0f, // +Z side
-1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-
- -1.0f,-1.0f, 1.0f, // Vertex 11
+ -1.0f,-1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
};
static const float g_uv_buffer_data[] = {
- 1.0f, 0.0f, // Vertex 0
- 0.0f, 0.0f,
- 0.0f, 1.0f,
-
- 0.0f, 1.0f, // Vertex 1
- 1.0f, 1.0f,
+ 0.0f, 0.0f, // -X side
1.0f, 0.0f,
-
-// 0.0f, 1.0f, // Vertex 2
-// 1.0f, 0.0f,
-// 0.0f, 0.0f,
-
-// 0.0f, 1.0f, // Vertex 3
-// 1.0f, 0.0f,
-// 1.0f, 1.0f,
-
- 0.0f, 0.0f, // Vertex 2
1.0f, 1.0f,
- 1.0f, 0.0f,
-
- 0.0f, 0.0f, // Vertex 3
- 0.0f, 1.0f,
1.0f, 1.0f,
-
- 0.0f, 1.0f, // Vertex 4
+ 0.0f, 1.0f,
0.0f, 0.0f,
- 1.0f, 0.0f,
- 0.0f, 1.0f, // Vertex 5
+ 1.0f, 0.0f, // -Z side
+ 0.0f, 1.0f,
+ 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
+ 0.0f, 1.0f,
- 0.0f, 1.0f, // Vertex 6
- 1.0f, 1.0f,
- 1.0f, 0.0f,
-
- 0.0f, 1.0f, // Vertex 7
+ 1.0f, 1.0f, // -Y side
1.0f, 0.0f,
0.0f, 0.0f,
-
- 0.0f, 1.0f, // Vertex 8
1.0f, 1.0f,
- 1.0f, 0.0f,
-
- 1.0f, 0.0f, // Vertex 9
0.0f, 0.0f,
0.0f, 1.0f,
- 1.0f, 1.0f, // Vertex 10
+ 1.0f, 1.0f, // +Y side
+ 0.0f, 1.0f,
+ 0.0f, 0.0f,
+ 1.0f, 1.0f,
+ 0.0f, 0.0f,
1.0f, 0.0f,
+
+ 1.0f, 1.0f, // +X side
0.0f, 1.0f,
+ 0.0f, 0.0f,
+ 0.0f, 0.0f,
+ 1.0f, 0.0f,
+ 1.0f, 1.0f,
- 1.0f, 0.0f, // Vertex 11
+ 0.0f, 1.0f, // +Z side
0.0f, 0.0f,
- 0.0f, 1.0f,
+ 1.0f, 1.0f,
+ 0.0f, 0.0f,
+ 1.0f, 0.0f,
+ 1.0f, 1.0f,
};
void dumpMatrix(const char *note, mat4x4 MVP)
@@ -1379,6 +1359,9 @@ static VkShader demo_prepare_vs(struct demo *demo)
"{\n"
" texcoord = ubuf.attr[gl_VertexID];\n"
" gl_Position = ubuf.MVP * ubuf.position[gl_VertexID];\n"
+ "\n"
+ " // GL->VK conventions\n"
+ " gl_Position.y = -gl_Position.y;\n"
"}\n";
return demo_prepare_shader(demo, VK_SHADER_STAGE_VERTEX,
@@ -1455,7 +1438,6 @@ static void demo_prepare_pipeline(struct demo *demo)
memset(&vp, 0, sizeof(vp));
vp.sType = VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO;
vp.viewportCount = 1;
- vp.clipOrigin = VK_COORDINATE_ORIGIN_LOWER_LEFT;
memset(&ds, 0, sizeof(ds));
ds.sType = VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO;
@@ -2035,7 +2017,7 @@ static void demo_init(struct demo *demo, int argc, char **argv)
{
vec3 eye = {0.0f, 3.0f, 5.0f};
vec3 origin = {0, 0, 0};
- vec3 up = {0.0f, -1.0f, 0.0};
+ vec3 up = {0.0f, 1.0f, 0.0};
memset(demo, 0, sizeof(*demo));
diff --git a/demos/cube.vert b/demos/cube.vert
index 5898c1fd..672bcced 100644
--- a/demos/cube.vert
+++ b/demos/cube.vert
@@ -15,4 +15,7 @@ void main()
{
texcoord = ubuf.attr[gl_VertexID];
gl_Position = ubuf.MVP * ubuf.position[gl_VertexID];
+
+ // GL->VK conventions
+ gl_Position.y = -gl_Position.y;
}