本文整理汇总了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();
}