本文整理汇总了C++中Drawable::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Drawable::Draw方法的具体用法?C++ Drawable::Draw怎么用?C++ Drawable::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drawable
的用法示例。
在下文中一共展示了Drawable::Draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
////////////////////////////////////////////////////////////
/// Draw something on the window
////////////////////////////////////////////////////////////
void RenderWindow::Draw(const Drawable& Object) const
{
// Check whether we are called from the outside or from a previous call to Draw
if (!myIsDrawing)
{
myIsDrawing = true;
// Set our window as the current target for rendering
if (SetActive())
{
// Save the current render states and set the SFML ones
if (myPreserveStates)
{
GLCheck(glMatrixMode(GL_MODELVIEW)); GLCheck(glPushMatrix());
GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glPushMatrix());
GLCheck(glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_ENABLE_BIT |
GL_TEXTURE_BIT | GL_TRANSFORM_BIT | GL_VIEWPORT_BIT));
SetRenderStates();
}
// Set the window viewport and transform matrices
GLCheck(glViewport(0, 0, GetWidth(), GetHeight()));
GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glLoadMatrixf(myCurrentView->GetMatrix().Get4x4Elements()));
GLCheck(glMatrixMode(GL_MODELVIEW)); GLCheck(glLoadIdentity());
// Let the object draw itself
Object.Draw(*this);
// Restore render states
if (myPreserveStates)
{
GLCheck(glMatrixMode(GL_PROJECTION)); GLCheck(glPopMatrix());
GLCheck(glMatrixMode(GL_MODELVIEW)); GLCheck(glPopMatrix());
GLCheck(glPopAttrib());
}
}
myIsDrawing = false;
}
else
{
// We are already called from a previous Draw : we don't need to set the states again, just draw the object
Object.Draw(*this);
}
}
示例2: runScene
int runScene(Drawable & scene){
glfwInit();
if( !glfwOpenWindow( 500, 500, 0,0,0,0, 16,0,
GLFW_WINDOW ) )
{
glfwTerminate();
}
glfwSetWindowTitle( "3D" );
glfwEnable( GLFW_STICKY_KEYS );
glfwEnable( GLFW_MOUSE_CURSOR );
glfwDisable( GLFW_AUTO_POLL_EVENTS );
setupCallbacks();
do //Main Loop.
{
setupProjection();
// stereo_state.Ping();
projection_state.Load();
float zoom=2.0;
glScalef(zoom*2.0/256.0, zoom*2.0/256.0, zoom*2.0/256.0);
glDisable (GL_BLEND);
glDisable(GL_LIGHTING);
glClear(GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
setupModelview();
/* Temporary light insertion:
*/
navigator.Draw();
//reference plane
DrawPlane(V3f(0,0,0), V3f(20,0,0), V3f(0,20,0), 5);
SetupLighting();
scene.Draw();
//Clear modified mouse state.
mouse_state.Moved();
glfwSwapBuffers();
if(!stereo_state.enabled){
glfwWaitEvents();
}else{
glfwPollEvents();
glfwSleep(0.01); //just sleep.
};
navigator.idle_move();
}
while(!glfwGetKey( GLFW_KEY_ESC ) &&
glfwGetWindowParam( GLFW_OPENED ));
return true;
};
示例3: Draw
void Renderer::Draw(Drawable & p_Drawable)
{
p_Drawable.Draw(*this);
}