upgrade examples

This commit is contained in:
hyzboy 2020-10-24 19:14:31 +08:00
parent 0d614b8902
commit 10c79f30a0
4 changed files with 36 additions and 12 deletions

View File

@ -91,7 +91,29 @@ private:
{
texture.sampler =db->CreateSampler();
VkSamplerCreateInfo sampler_create_info=
{
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
nullptr,
0,
VK_FILTER_LINEAR,
VK_FILTER_LINEAR,
VK_SAMPLER_MIPMAP_MODE_LINEAR,
VK_SAMPLER_ADDRESS_MODE_REPEAT,
VK_SAMPLER_ADDRESS_MODE_REPEAT,
VK_SAMPLER_ADDRESS_MODE_REPEAT,
0.0f,
false,
0,
false,
VK_COMPARE_OP_NEVER,
0.0f,
1.0f,
VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
false
};
texture.sampler =db->CreateSampler(&sampler_create_info);
texture.color =db->LoadTexture2D(OS_TEXT("res/image/Brickwall/Albedo.Tex2D"));
texture.normal =db->LoadTexture2D(OS_TEXT("res/image/Brickwall/Normal.Tex2D"));
@ -147,6 +169,9 @@ private:
tci.numberSlices=128;
tci.numberStacks=64;
tci.uv_scale.x=4;
tci.uv_scale.y=1;
ro_torus=CreateRenderableTorus(db,material,&tci);
}

View File

@ -20,10 +20,10 @@ constexpr float vertex_data[VERTEX_COUNT][2]=
{SCREEN_WIDTH*0.25, SCREEN_HEIGHT*0.75}
};
constexpr float color_data[VERTEX_COUNT][3]=
{ {1,0,0},
{0,1,0},
{0,0,1}
constexpr float color_data[VERTEX_COUNT][4]=
{ {1,0,0,1},
{0,1,0,1},
{0,0,1,1}
};
class TestApp:public VulkanApplicationFramework
@ -78,7 +78,7 @@ private:
if(!render_obj)return(false);
if(!render_obj->Set(VAN::Position, db->CreateVAB(VAF_VEC2,VERTEX_COUNT,vertex_data)))return(false);
if(!render_obj->Set(VAN::Color, db->CreateVAB(VAF_VEC3,VERTEX_COUNT,color_data)))return(false);
if(!render_obj->Set(VAN::Color, db->CreateVAB(VAF_VEC4,VERTEX_COUNT,color_data)))return(false);
render_instance=db->CreateRenderableInstance(render_obj,material_instance,pipeline);
return(true);
@ -100,7 +100,8 @@ public:
if(!InitVBO())
return(false);
BuildCommandBuffer(render_instance);
if(!BuildCommandBuffer(render_instance))
return(false);
return(true);
}

View File

@ -66,11 +66,9 @@ private:
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D);
if(!pipeline)return(false);
texture=CreateTextureFromFile(device,OS_TEXT("res/image/lena.Tex2D"));
texture=db->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"));
if(!texture)return(false);
db->Add(texture);
sampler=db->CreateSampler();
material_instance->BindSampler("tex",texture,sampler);