改为有vertex input的测试
This commit is contained in:
parent
13dfb99af9
commit
e9408e9b24
@ -81,7 +81,7 @@ PipelineCreater::PipelineCreater(Device *dev)
|
||||
rasterizer.rasterizerDiscardEnable = VK_FALSE;
|
||||
rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
|
||||
rasterizer.cullMode = VK_CULL_MODE_FRONT_AND_BACK;
|
||||
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
|
||||
rasterizer.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
|
||||
rasterizer.depthBiasEnable = VK_FALSE;
|
||||
rasterizer.depthBiasConstantFactor = 0;
|
||||
rasterizer.depthBiasClamp = 0;
|
||||
|
@ -70,43 +70,43 @@ vulkan::Shader *LoadShader(VkDevice device)
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
//constexpr float vertex_data[]={0.0f,0.5f, -0.5f,-0.5f, 0.5f,-0.5f };
|
||||
//constexpr float color_data[]={1,0,0, 0,1,0, 0,0,1 };
|
||||
//
|
||||
//vulkan::VertexBuffer *vertex_buffer=nullptr;
|
||||
//vulkan::VertexBuffer *color_buffer=nullptr;
|
||||
//
|
||||
//vulkan::VertexInput *CreateVertexBuffer(vulkan::Device *dev)
|
||||
//{
|
||||
// vertex_buffer=dev->CreateVBO(FMT_RG32F,6*sizeof(float));
|
||||
// color_buffer=dev->CreateVBO(FMT_RGB32F,9*sizeof(float));
|
||||
//
|
||||
// {
|
||||
// float *p=(float *)vertex_buffer->Map();
|
||||
//
|
||||
// memcpy(p,vertex_data,6*sizeof(float));
|
||||
//
|
||||
// vertex_buffer->Unmap();
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// float *p=(float *)color_buffer->Map();
|
||||
//
|
||||
// memcpy(p,color_data,9*sizeof(float));
|
||||
//
|
||||
// color_buffer->Unmap();
|
||||
// }
|
||||
//
|
||||
// vulkan::VertexInput *vi=new vulkan::VertexInput();
|
||||
//
|
||||
// constexpr uint32_t position_shader_location=0; //对应shader中的layout(locaiton=0,暂时这样写
|
||||
// constexpr uint32_t color_shader_location=1;
|
||||
//
|
||||
// vi->Add(position_shader_location, vertex_buffer);
|
||||
// vi->Add(color_shader_location, color_buffer);
|
||||
//
|
||||
// return vi;
|
||||
//}
|
||||
constexpr float vertex_data[]={0.0f,0.5f, -0.5f,-0.5f, 0.5f,-0.5f };
|
||||
constexpr float color_data[]={1,0,0, 0,1,0, 0,0,1 };
|
||||
|
||||
vulkan::VertexBuffer *vertex_buffer=nullptr;
|
||||
vulkan::VertexBuffer *color_buffer=nullptr;
|
||||
|
||||
vulkan::VertexInput *CreateVertexBuffer(vulkan::Device *dev)
|
||||
{
|
||||
vertex_buffer=dev->CreateVBO(FMT_RG32F,6*sizeof(float));
|
||||
color_buffer=dev->CreateVBO(FMT_RGB32F,9*sizeof(float));
|
||||
|
||||
{
|
||||
float *p=(float *)vertex_buffer->Map();
|
||||
|
||||
memcpy(p,vertex_data,6*sizeof(float));
|
||||
|
||||
vertex_buffer->Unmap();
|
||||
}
|
||||
|
||||
{
|
||||
float *p=(float *)color_buffer->Map();
|
||||
|
||||
memcpy(p,color_data,9*sizeof(float));
|
||||
|
||||
color_buffer->Unmap();
|
||||
}
|
||||
|
||||
vulkan::VertexInput *vi=new vulkan::VertexInput();
|
||||
|
||||
constexpr uint32_t position_shader_location=0; //对应shader中的layout(locaiton=0,暂时这样写
|
||||
constexpr uint32_t color_shader_location=1;
|
||||
|
||||
vi->Add(position_shader_location, vertex_buffer);
|
||||
vi->Add(color_shader_location, color_buffer);
|
||||
|
||||
return vi;
|
||||
}
|
||||
|
||||
void wait_seconds(int seconds) {
|
||||
#ifdef WIN32
|
||||
@ -171,7 +171,7 @@ int main(int,char **)
|
||||
|
||||
vulkan::Semaphore *sem=device->CreateSem();
|
||||
|
||||
// vulkan::VertexInput *vi=CreateVertexBuffer(device);
|
||||
vulkan::VertexInput *vi=CreateVertexBuffer(device);
|
||||
|
||||
vulkan::PipelineCreater pc(device);
|
||||
vulkan::RenderPass *rp=device->CreateRenderPass();
|
||||
@ -181,7 +181,7 @@ int main(int,char **)
|
||||
vulkan::PipelineLayout *pl=CreatePipelineLayout(device->GetDevice(),dsl);
|
||||
|
||||
pc.Set(shader);
|
||||
//pc.Set(vi);
|
||||
pc.Set(vi);
|
||||
pc.Set(PRIM_TRIANGLES);
|
||||
pc.Set(*pl);
|
||||
pc.Set(*rp);
|
||||
@ -202,7 +202,7 @@ int main(int,char **)
|
||||
cmd_buf->Begin(rp,fb[0]);
|
||||
cmd_buf->Bind(pipeline);
|
||||
cmd_buf->Bind(pl);
|
||||
// cmd_buf->Bind(vi);
|
||||
cmd_buf->Bind(vi);
|
||||
cmd_buf->Draw(3);
|
||||
cmd_buf->End();
|
||||
|
||||
@ -224,7 +224,7 @@ int main(int,char **)
|
||||
delete sem;
|
||||
delete rp;
|
||||
|
||||
// delete vi;
|
||||
delete vi;
|
||||
// delete ubo;
|
||||
|
||||
delete shader;
|
||||
|
Loading…
x
Reference in New Issue
Block a user