本文整理汇总了C++中VertexShader::loadFromBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexShader::loadFromBuffer方法的具体用法?C++ VertexShader::loadFromBuffer怎么用?C++ VertexShader::loadFromBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexShader
的用法示例。
在下文中一共展示了VertexShader::loadFromBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mRange
UserInterface::UserInterface(float inRange) : mRange(inRange), mRatio(0.0f),
mMouseX(0.0f), mMouseY(0.0f), mMouseOverWidget(NULL),
mClickCandidate(NULL), mModelViewProjection(mMatrix)
{
if (mRange < 1.0f) mRange = 1.0f;
VertexShader vs;
const char* vertexShader =
"#version 120\n"
"uniform mat4 uMVPM;\n"
"attribute vec2 iPosition;\n"
"attribute vec2 iTexture;\n"
"varying vec2 vTexture;\n"
"void main(void)\n"
"{\n"
" vTexture = iTexture;\n"
" vec4 p = vec4(iPosition, 0.0, 1.0);\n"
" gl_Position = uMVPM * p;\n"
"}\n"
;
vs.loadFromBuffer(vertexShader);
FragmentShader fs;
const char* fragmentShader =
"#version 120\n"
"uniform sampler2D uTexture;\n"
"varying vec2 vTexture;\n"
"void main(void)\n"
"{\n"
" gl_FragColor = texture2D(uTexture, vTexture);\n"
"}\n"
;
fs.loadFromBuffer(fragmentShader);
mProgram.attachShader(vs);
mProgram.attachShader(fs);
mProgram.bindAttribLocation(0, "iVertex");
mProgram.bindAttribLocation(1, "iTexture");
mProgram.link();
mUniMVPM = mProgram.getUniformLocation("uMVPM");
mUniTexture = mProgram.getUniformLocation("uTexture");
glUniform1i(mUniTexture, 0);
}