|
3 | 3 |
|
4 | 4 | using namespace std;
|
5 | 5 |
|
6 |
| -const std::vector<VK_Vertex> vertices1 = { |
7 |
| - {{0.0f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
8 |
| - {{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
9 |
| - {{-0.5f, 0.5f, 0.0f}, {1.0f, 0.0f, 0.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}} |
| 6 | +const std::vector<float> vertices1 = { |
| 7 | + 0.0f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f, |
| 8 | + 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, |
| 9 | + -0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.5f |
10 | 10 | };
|
11 | 11 |
|
12 |
| -const std::vector<VK_Vertex> vertices2 = { |
13 |
| - {{-0.5f, -0.3f, 0.0f}, {1.0f, 1.0f, 1.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
14 |
| - {{0.5f, -0.3f, 0.0f}, {1.0f, 1.0f, 1.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
15 |
| - {{0.5f, 0.3f, 0.0f}, {1.0f, 1.0f, 1.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
16 |
| - {{0.5f, 0.3f, 0.0f}, {1.0f, 1.0f, 1.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
17 |
| - {{-0.5f, 0.3f, 0.0f}, {1.0f, 1.0f, 1.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
18 |
| - {{-0.5f, -0.3f, 0.0f}, {1.0f, 1.0f, 1.0f, 0.5f}, {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f}}, |
19 |
| -}; |
| 12 | +const std::vector<float> vertices2 = { |
| 13 | + -0.5f, -0.3f, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f, |
| 14 | + 0.5f, -0.3f, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f, |
| 15 | + 0.5f, 0.3f, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f, |
| 16 | + 0.5f, 0.3f, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f, |
| 17 | + -0.5f, 0.3f, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f, |
| 18 | + -0.5f, -0.3f, 0.0f, 1.0f, 1.0f, 1.0f, 0.5f |
| 19 | + }; |
20 | 20 |
|
21 | 21 | VK_Context* context = nullptr;
|
22 | 22 |
|
@@ -50,25 +50,29 @@ int main()
|
50 | 50 | context->createWindow(640, 480, true);
|
51 | 51 |
|
52 | 52 | VK_Context::VK_Config vkConfig;
|
53 |
| - context->initVulkan(vkConfig); |
| 53 | + context->initVulkanDevice(vkConfig); |
54 | 54 |
|
55 | 55 | auto shaderSet = context->createShaderSet();
|
56 | 56 | shaderSet->addShader("shader/vertex/vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
57 | 57 | shaderSet->addShader("shader/vertex/frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
58 | 58 |
|
| 59 | + shaderSet->appendAttributeDescription(0, sizeof (float) * 3); |
| 60 | + shaderSet->appendAttributeDescription(1, sizeof (float) * 4); |
| 61 | + |
59 | 62 | if(!shaderSet->isValid()) {
|
60 | 63 | std::cerr << "invalid shaderSet" << std::endl;
|
61 | 64 | shaderSet->release();
|
62 | 65 | context->release();
|
63 | 66 | return -1;
|
64 | 67 | }
|
65 | 68 |
|
| 69 | + context->initVulkanContext(); |
66 | 70 | context->initPipeline(shaderSet);
|
67 | 71 |
|
68 |
| - auto buffer = context->createVertexBuffer(vertices1); |
| 72 | + auto buffer = context->createVertexBuffer(vertices1, 7); |
69 | 73 | context->addBuffer(buffer);
|
70 | 74 |
|
71 |
| - buffer = context->createVertexBuffer(vertices2); |
| 75 | + buffer = context->createVertexBuffer(vertices2, 7); |
72 | 76 | context->addBuffer(buffer);
|
73 | 77 |
|
74 | 78 | context->createCommandBuffers();
|
|
0 commit comments