// Renderer.cpp: implementation of the CScene class.
//
//////////////////////////////////////////////////////////////////////
#include "scene.h"
#include "application.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CScene::CScene()
{
pCamera = new CCamera();
}
CScene::~CScene()
{
OutputDebugString("CScene destructor\n");
}
bool CScene::Init()
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-50.0, 50.0, -50.0, 50.0, -50.0, 50.0);
return TRUE; // Initialization Went OK
}
void CScene::Resize()
{
// prevent division by 0
if (pApp->pData->Window_Height==0)
{
pApp->pData->Window_Height=1;
}
pApp->pLog->Log("New window size: %d x %d",
pApp->pData->Window_Width, pApp->pData->Window_Height);
glViewport(0,0,pApp->pData->Window_Width, pApp->pData->Window_Height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,
(GLfloat)pApp->pData->Window_Width /(GLfloat)pApp->pData->Window_Height,
0.1f,100.0f);
// Create Ortho 640x480 View (0,0 At Top Left)
//glOrtho(-50.0f,50.0f,-50.0f,50.0f,-10.0f,10.0f);
// Select The Modelview Matrix
glMatrixMode(GL_MODELVIEW);
// Reset The Modelview Matrix
glLoadIdentity();
}
void CScene::Clear()
{
// Clear The Screen And The Depth Buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
}