本文整理汇总了C++中GLSLProgram::SetVertexShaderSource方法的典型用法代码示例。如果您正苦于以下问题:C++ GLSLProgram::SetVertexShaderSource方法的具体用法?C++ GLSLProgram::SetVertexShaderSource怎么用?C++ GLSLProgram::SetVertexShaderSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLSLProgram
的用法示例。
在下文中一共展示了GLSLProgram::SetVertexShaderSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
//------------------------------------------------------------------------------
static bool
linkDefaultPrograms() {
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
#define GLSL_VERSION_DEFINE "#version 400\n"
#else
#define GLSL_VERSION_DEFINE "#version 150\n"
#endif
{ // setup samples program
//
// this shader takes position, uTangent and vTangent for each point
// then generates 3 lines in the geometry shader.
//
static const char *vsSrc =
GLSL_VERSION_DEFINE
"in vec3 position;\n"
"in vec3 uTangent;\n"
"in vec3 vTangent;\n"
"out vec3 p;\n"
"out vec3 ut;\n"
"out vec3 vt;\n"
"uniform mat4 ModelViewMatrix;\n"
"void main() {\n"
" p = (ModelViewMatrix * vec4(position, 1)).xyz;\n"
" ut = (ModelViewMatrix * vec4(uTangent, 0)).xyz;\n"
" vt = (ModelViewMatrix * vec4(vTangent, 0)).xyz;\n"
"}\n";
static const char *gsSrc =
GLSL_VERSION_DEFINE
"layout(points) in;\n"
"layout(line_strip, max_vertices = 6) out;\n"
"in vec3 p[];\n"
"in vec3 ut[];\n"
"in vec3 vt[];\n"
"out vec4 c;\n"
"uniform mat4 ProjectionMatrix;\n"
"uniform float scale;\n"
"void main() {\n"
" vec3 pos = p[0]; \n"
" c = vec4(1, 0, 0, 1);\n"
" gl_Position = ProjectionMatrix * vec4(pos, 1);\n"
" EmitVertex();\n"
" \n"
" pos = p[0] + ut[0] * scale; \n"
" gl_Position = ProjectionMatrix * vec4(pos, 1);\n"
" EmitVertex();\n"
" EndPrimitive();\n"
" \n"
" pos = p[0]; \n"
" c = vec4(0, 1, 0, 1);\n"
" gl_Position = ProjectionMatrix * vec4(pos, 1);\n"
" EmitVertex();\n"
" \n"
" pos = p[0] + vt[0] * scale; \n"
" gl_Position = ProjectionMatrix * vec4(pos, 1);\n"
" EmitVertex();\n"
" EndPrimitive();\n"
" \n"
" pos = p[0]; \n"
" c = vec4(0, 0, 1, 1);\n"
" gl_Position = ProjectionMatrix * vec4(pos, 1);\n"
" EmitVertex();\n"
" \n"
" pos = p[0] + cross(ut[0], vt[0]) * scale; \n"
" gl_Position = ProjectionMatrix * vec4(pos, 1);\n"
" EmitVertex();\n"
" EndPrimitive();\n"
" \n"
"}\n";
static const char *fsSrc =
GLSL_VERSION_DEFINE
"in vec4 c;\n"
"out vec4 color;\n"
"void main() {\n"
" color = c;\n"
"}\n";
g_samplesProgram.SetVertexShaderSource(vsSrc);
g_samplesProgram.SetGeometryShaderSource(gsSrc);
g_samplesProgram.SetFragShaderSource(fsSrc);
g_samplesProgram.AddAttribute( "position",3 );
g_samplesProgram.AddAttribute( "uTangent",3 );
g_samplesProgram.AddAttribute( "vTangent",3 );
}
return true;
}
示例2: defined
//------------------------------------------------------------------------------
static bool
linkDefaultPrograms() {
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
#define GLSL_VERSION_DEFINE "#version 400\n"
#else
#define GLSL_VERSION_DEFINE "#version 150\n"
#endif
{ // setup control cage program
static const char *vsSrc =
GLSL_VERSION_DEFINE
"in vec3 position;\n"
"in vec3 color;\n"
"out vec4 fragColor;\n"
"uniform mat4 ModelViewProjectionMatrix;\n"
"void main() {\n"
" fragColor = vec4(color, 1);\n"
" gl_Position = ModelViewProjectionMatrix * "
" vec4(position, 1);\n"
"}\n";
static const char *fsSrc =
GLSL_VERSION_DEFINE
"in vec4 fragColor;\n"
"out vec4 color;\n"
"void main() {\n"
" color = fragColor;\n"
"}\n";
g_cageProgram.SetVertexShaderSource(vsSrc);
g_cageProgram.SetFragShaderSource(fsSrc);
g_cageProgram.AddAttribute( "position",3 );
g_cageProgram.AddAttribute( "color",3 );
}
{ // setup samples program
static const char *vsSrc =
GLSL_VERSION_DEFINE
"in vec3 position;\n"
"uniform mat4 ModelViewProjectionMatrix;\n"
"void main() {\n"
" gl_Position = ModelViewProjectionMatrix * "
" vec4(position, 1);\n"
"}\n";
static const char *fsSrc =
GLSL_VERSION_DEFINE
"out vec4 color;\n"
"const vec4 colors[3] = vec4[3]( vec4(1.0,0.0,0.0,1.0), \n"
" vec4(0.0,1.0,0.0,1.0), \n"
" vec4(0.0,0.0,1.0,1.0) ); \n"
"void main() {\n"
" color = colors[gl_PrimitiveID % 3];\n"
"}\n";
g_samplesProgram.SetVertexShaderSource(vsSrc);
g_samplesProgram.SetFragShaderSource(fsSrc);
g_samplesProgram.AddAttribute( "position",3 );
}
return true;
}