当前位置: 首页>>代码示例>>C++>>正文


C++ WorldState::getMousePosx方法代码示例

本文整理汇总了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");
}
开发者ID:mimaun,项目名称:Rose,代码行数:73,代码来源:main.cpp


注:本文中的WorldState::getMousePosx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。