Beispiel #1
0
void RenderScene() 
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();									// Reset The matrix

	// Position the camera
	g_Camera.Look();

	// Each frame we calculate the new frustum.  In reality you only need to
	// calculate the frustum when we move the camera.
	g_Frustum.CalculateFrustum();

	// Initialize the total node count that is being draw per frame
	g_TotalNodesDrawn = 0;

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// Here we draw the octree, starting with the root node and recursing down each node.
	// This time, we pass in the root node and just the original world model.  You could
	// just store the world in the root node and not have to keep the original data around.
	// This is up to you.  I like this way better because it's easy, though it could be 
	// more error prone.
	g_Octree.DrawOctree(&g_Octree, &g_World);

	// Render the cubed nodes to visualize the octree (in wire frame mode)
	if( g_bDisplayNodes )
		g_Debug.RenderDebugLines();

	// Create a buffer to store the octree information for the title bar
	static char strBuffer[255] = {0};

	// Display in window mode the current subdivision information.  We now display the
	// max triangles per node, the max level of subdivision, total end nodes, current nodes drawn
	// and frames per second we are receiving.  
	sprintf(strBuffer, "Triangles: %d        Subdivisions: %d        EndNodes: %d          NodesDraw: %d          FPS: %s",
		                g_MaxTriangles,		 g_MaxSubdivisions,		 g_EndNodeCount,	   g_TotalNodesDrawn,	  g_strFrameRate);

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *


	// Set our window title bar to the subdivision information
	SetWindowText(g_hWnd, strBuffer);

	// Swap the backbuffers to the foreground
	SwapBuffers(g_hDC);									
}
Beispiel #2
0
void RenderScene()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
    glLoadIdentity();									// Reset The matrix

    // Give OpenGL our camera position
    g_Camera.Look();

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

    // Each frame we calculate the new frustum.  In reality you only need to
    // calculate the frustum when we move the camera.
    g_Frustum.CalculateFrustum();

    // Initialize the total node count that is being draw per frame
    g_TotalNodesDrawn = 0;

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

    // Here we draw the octree, starting with the root node and recursing down each node.
    // When we get to each of the end nodes we will draw the vertices assigned to them.
    g_Octree.DrawOctree(&g_Octree);

    // Render the cube'd nodes to visualize the octree (in wire frame mode)
    g_Debug.RenderDebugLines();

    SwapBuffers(g_hDC);									// Swap the backbuffers to the foreground

    char strBuffer[255] = {0};							// Create a character buffer

    // To view our octree information I set the window's title bar to the some basic
    // information such as the max triangles per node, the max subdivisions,
    // total end nodes and the total drawn end nodes that are currently in the frustum.

    // Display in window mode the current subdivision information
    sprintf(strBuffer, "MaxTriangles: %d     MaxSubdivisions: %d     TotalEndNodes: %d       TotalNodesDraw: %d",
            g_MaxTriangles,		 g_MaxSubdivisions,		 g_EndNodeCount,		 g_TotalNodesDrawn);

    // Set our window title bar to the subdivision data
    SetWindowText(g_hWnd, strBuffer);
}