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


C++ G3D::Vector2方法代码示例

本文整理汇总了C++中G3D::Vector2方法的典型用法代码示例。如果您正苦于以下问题:C++ G3D::Vector2方法的具体用法?C++ G3D::Vector2怎么用?C++ G3D::Vector2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在G3D的用法示例。


在下文中一共展示了G3D::Vector2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: display

void Image::display(float deviceGamma) const {
    int argc = 0;
    
    // Initialize OpenGL
    glutInit(&argc, NULL);
    glutInitWindowSize(m_width, m_height);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    glutCreateWindow("G3D");
    glutKeyboardFunc(&quitOnEscape);
    glutDisplayFunc(&render);

    // Initialize OpenGL extensions
    glewInit();

    // Set the color scale applied as textures are uploaded to be the exposure constant
    glMatrixMode(GL_COLOR);
    glLoadIdentity();
    glScalef(m_exposureConstant, m_exposureConstant, m_exposureConstant);

    // Create a gamma correction color table for texture load
    std::vector<Color3> gammaTable(256);
    for (unsigned int i = 0; i < gammaTable.size(); ++i) {
        gammaTable[i] = (Color3::white() * i / (gammaTable.size() - 1.0f)).pow(1.0f / deviceGamma);
    }
    glColorTable(GL_POST_COLOR_MATRIX_COLOR_TABLE, GL_RGB, (GLsizei)gammaTable.size(), GL_RGB, GL_FLOAT, &gammaTable[0]);
    glEnable(GL_POST_COLOR_MATRIX_COLOR_TABLE);
    
    // Create a texture, upload our image, and bind it (assume a
    // version of GL that supports NPOT textures)
    GLuint texture;
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_width, m_height, 0, GL_RGB, GL_FLOAT, &m_data[0]);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    glEnable(GL_TEXTURE_2D);

    // The vertices of a 2D quad mesh containing a single CCW square
    static const Vector2 corner[] = {Vector2(0,0), Vector2(0,1), Vector2(1,1), Vector2(1,0)};

    // Bind the quad mesh as the active geometry
    glVertexPointer(2, GL_FLOAT, 0, corner);
    glTexCoordPointer(2, GL_FLOAT, 0, corner);
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    
    // Set orthographic projection that stretches the unit square to the
    // dimensions of the image
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 1, 1, 0, 0, 2);
    glutMainLoop();
}
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:56,代码来源:supportclasses.cpp


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