本文整理汇总了C++中model::drawBox方法的典型用法代码示例。如果您正苦于以下问题:C++ model::drawBox方法的具体用法?C++ model::drawBox怎么用?C++ model::drawBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::drawBox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Display
void Display(){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
//View1 LEFT /////////////////////////////
//Set the viewport and projection matrix.
glViewport(0,0,windowWidth,windowHeight); //Set the viewport
glMatrixMode(GL_PROJECTION); //Set projection matrix.
glLoadIdentity(); //Reset projection matrix.
glOrtho(-1, 1, -1, 1, 0.0001f, 1000); //Orthographic projection.
//Change to modelview in order to draw.
glMatrixMode(GL_MODELVIEW); //Set modelview matrix.
glLoadIdentity(); //Reset modelview matrix.
//Set rendering parameters if needed.
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); //Set polygon render mode.
//Set camera.
gluLookAt(0, 0, -10, 0, 0, 0, 0, 1, 0);
//Draw stuff.
// view1.drawSquare();
//TEXTURING /////////////////
glEnable(GL_TEXTURE_2D);
//LOAD TEXTURE FROM FILE
img_data.loadFromFile("images/box.bmp");
//Generate OpenGL texture object
glGenTextures(1, &texture_handle);
//Binds texture (this texture will be mapped to polygons)
glBindTexture(GL_TEXTURE_2D, texture_handle);
// Upload data to GPU
glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA,
img_data.getSize().x, img_data.getSize().y, 0,
GL_RGBA, GL_UNSIGNED_BYTE, img_data.getPixelsPtr()
);
// some texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
if (currentState == MAIN)
{
view1.drawSquare();
}
//View 2 RIGHT
//Set the viewport and projection matrix.
glViewport(0, 0, windowWidth, windowHeight);//viewport size
glMatrixMode(GL_PROJECTION); //Set projection matrix.
glLoadIdentity(); //Reset projection matrix.
gluPerspective(60, 1, 0.1f, 1000); //Perspective
//Change to modelview in order to draw.
glMatrixMode(GL_MODELVIEW); //Set modelview matrix.
glLoadIdentity(); //Reset modelview matrix.
//Set rendering parameters if needed.
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); //Set polygon render mode.
//Set camera.
gluLookAt(view2.eye.x, view2.eye.y, view2.eye.z,
view2.tar.x+view2.eye.x, view2.tar.y+view2.eye.y, view2.tar.z,
0, 1, 0);
//Draw stuff.
if (currentState == GAME)
{
Test.drawBox(-24,22,0,0.4);
drawShapes();
}
}