本文整理汇总了C++中shapes::Cube::EdgeInstructions方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::EdgeInstructions方法的具体用法?C++ Cube::EdgeInstructions怎么用?C++ Cube::EdgeInstructions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapes::Cube
的用法示例。
在下文中一共展示了Cube::EdgeInstructions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attr
DOFExample(const ExampleParams& params)
: face_instr(make_cube.Instructions())
, edge_instr(make_cube.EdgeInstructions())
, face_indices(make_cube.Indices())
, edge_indices(make_cube.EdgeIndices())
, cube_matrices(MakeCubeMatrices(100, 10.0))
, viewport_width(dof_prog, "ViewportWidth")
, viewport_height(dof_prog, "ViewportHeight")
, projection_matrix(main_prog, "ProjectionMatrix")
, camera_matrix(main_prog, "CameraMatrix")
, model_matrix(main_prog, "ModelMatrix")
, ambient_color(main_prog, "AmbientColor")
, diffuse_color(main_prog, "DiffuseColor")
, focus_depth(dof_prog, "FocusDepth")
, color_tex(Texture::Target::Rectangle)
, depth_tex(Texture::Target::Rectangle)
, width(800)
, height(600)
{
main_vs.Source(
"#version 330\n"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"uniform vec3 LightPos;"
"in vec4 Position;"
"in vec3 Normal;"
"out vec3 vertLightDir;"
"out vec3 vertNormal;"
"void main(void)"
"{"
" gl_Position = ModelMatrix * Position;"
" vertLightDir = normalize(LightPos - gl_Position.xyz);"
" vertNormal = normalize(mat3(ModelMatrix)*Normal);"
" gl_Position = ProjectionMatrix * CameraMatrix * gl_Position;"
"}"
);
// compile it
main_vs.Compile();
// set the fragment shader source
main_fs.Source(
"#version 330\n"
"uniform vec3 AmbientColor, DiffuseColor;"
"in vec3 vertLightDir;"
"in vec3 vertNormal;"
"out vec4 fragColor;"
"void main(void)"
"{"
" float d = max(dot(vertLightDir,vertNormal),0.0);"
" float e = sin("
" 10.0*vertLightDir.x + "
" 20.0*vertLightDir.y + "
" 25.0*vertLightDir.z "
" )*0.9;"
" fragColor = vec4("
" mix(AmbientColor, DiffuseColor, d+e),"
" 1.0"
" );"
"}"
);
// compile it
main_fs.Compile();
// attach the shaders to the program
main_prog.AttachShader(main_vs);
main_prog.AttachShader(main_fs);
// link and use it
main_prog.Link();
main_prog.Use();
// bind the VAO for the cube
cube.Bind();
// bind the VBO for the cube vertices
positions.Bind(Buffer::Target::Array);
{
std::vector<GLfloat> data;
GLuint n_per_vertex = make_cube.Positions(data);
// upload the data
Buffer::Data(Buffer::Target::Array, data);
// setup the vertex attribs array for the vertices
VertexAttribArray attr(main_prog, "Position");
attr.Setup<GLfloat>(n_per_vertex);
attr.Enable();
}
// bind the VBO for the cube normals
normals.Bind(Buffer::Target::Array);
{
std::vector<GLfloat> data;
GLuint n_per_vertex = make_cube.Normals(data);
Buffer::Data(Buffer::Target::Array, data);
VertexAttribArray attr(main_prog, "Normal");
attr.Setup<GLfloat>(n_per_vertex);
attr.Enable();
}
Uniform<Vec3f>(main_prog, "LightPos").Set(30.0, 50.0, 20.0);
dof_vs.Source(
"#version 330\n"
//.........这里部分代码省略.........