本文整理汇总了C++中WorldState::getMousePosx方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldState::getMousePosx方法的具体用法?C++ WorldState::getMousePosx怎么用?C++ WorldState::getMousePosx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldState
的用法示例。
在下文中一共展示了WorldState::getMousePosx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
/*
Draw a single frame
*/
void display(WorldState & state)
{
// Clear the color bits in the display buffer
glClear(GL_COLOR_BUFFER_BIT);
// Use a simple shader to render the line
glUseProgram(shaderProg);
checkGLError("useProgram");
//use the vertex array
glBindVertexArray(vertexArray);
//get uniform slot id
//TODO: send a uniform value to the shader
GLint timeSlot = glGetUniformLocation(shaderProg, "timeVal");
glUniform1f(timeSlot, state.getCurrentTime());
GLint mousexSlot = glGetUniformLocation(shaderProg, "mousexVal");
glUniform1i(mousexSlot, state.getMousePosx());
checkGLError("uniform");
// Render using vertex attributes (data already on GPU) (~2008, 3.0)
// https://web.archive.org/web/20150225192608/http://www.arcsynthesis.org/gltut/Basics/Tut01%20Following%20the%20Data.html
// Tell OpenGL we want to use a buffer on the GPU
glBindBuffer(GL_ARRAY_BUFFER, positionBuffer);
checkGLError("bind pos buffer");
// Tell OpenGL what shader data slot we want to use
glEnableVertexAttribArray(positionSlot);
checkGLError("enable pos slot");
// Tell OpenGL how to interpret the data
glVertexAttribPointer(positionSlot, 2, GL_FLOAT, GL_FALSE, 0, 0);
checkGLError("vertex attrib pos");
// Do the same thing for colors
glBindBuffer(GL_ARRAY_BUFFER, colorBuffer);
glEnableVertexAttribArray(colorSlot);
glVertexAttribPointer(colorSlot, 3, GL_FLOAT, GL_FALSE, 0, 0);
checkGLError("color array setup");
glBindBuffer(GL_ARRAY_BUFFER, sizeBuffer);
checkGLError("bind size buffer");
glEnableVertexAttribArray(sizeSlot);
checkGLError("enable size slot");
glVertexAttribPointer(sizeSlot, 1, GL_FLOAT, GL_FALSE, 0, 0);
checkGLError("size array setup");
// Draw some primitives as: glDrawArrays(type, first, count)
//TODO: replace these with your draw calls
glDrawArrays(GL_TRIANGLES, 0, 12);
glDrawArrays(GL_POINTS, 12, 1);
//done with the vertex array
glBindVertexArray(0);
// Tell OpenGL we are done with the buffer
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Tell OpenGL we are done with the shader
glUseProgram(0);
checkGLError("unbind");
}