implement singleton pattern
This commit is contained in:
@@ -8,24 +8,10 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// public constructor/destructor
|
||||
|
||||
OpenGLController::OpenGLController() :
|
||||
iWidth(640),
|
||||
iHeight(480),
|
||||
camera(iWidth, iHeight)
|
||||
OpenGLController& OpenGLController::getInstance(int oglMajor, int oglMinor)
|
||||
{
|
||||
initDefault();
|
||||
processInit();
|
||||
}
|
||||
|
||||
OpenGLController::OpenGLController(int oglMajor, int oglMinor) :
|
||||
iWidth(640),
|
||||
iHeight(480),
|
||||
camera(iWidth, iHeight)
|
||||
{
|
||||
initDefault();
|
||||
iOglMajorVersion = oglMajor;
|
||||
iOglMinorVersion = oglMinor;
|
||||
processInit();
|
||||
static OpenGLController instace(oglMajor, oglMinor);
|
||||
return instace;
|
||||
}
|
||||
|
||||
OpenGLController::~OpenGLController()
|
||||
@@ -35,6 +21,20 @@ OpenGLController::~OpenGLController()
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// private constructor
|
||||
|
||||
OpenGLController::OpenGLController(int oglMajor, int oglMinor) :
|
||||
iWidth(640),
|
||||
iHeight(480)
|
||||
{
|
||||
camera = new Camera(iWidth, iHeight);
|
||||
initDefault();
|
||||
iOglMajorVersion = oglMajor;
|
||||
iOglMinorVersion = oglMinor;
|
||||
processInit();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// private functions
|
||||
|
||||
@@ -141,7 +141,7 @@ void OpenGLController::setCallbackFunctions()
|
||||
|
||||
glm::mat4 OpenGLController::getMVPMatrix()
|
||||
{
|
||||
return camera.getMatrix() * object->getMatrix();
|
||||
return camera->getMatrix() * object->getMatrix();
|
||||
}
|
||||
|
||||
GLFWwindow * OpenGLController::getWindow() const
|
||||
@@ -155,7 +155,7 @@ GLFWwindow * OpenGLController::getWindow() const
|
||||
|
||||
void OpenGLController::resize(int width, int height)
|
||||
{
|
||||
camera.setSize(width, height);
|
||||
camera->setSize(width, height);
|
||||
}
|
||||
|
||||
void OpenGLController::addRotX(float value)
|
||||
@@ -170,17 +170,17 @@ void OpenGLController::addRotY(float value)
|
||||
|
||||
void OpenGLController::addTransX(double value)
|
||||
{
|
||||
camera.add2x(value);
|
||||
camera->add2x(value);
|
||||
}
|
||||
|
||||
void OpenGLController::addTransY(double value)
|
||||
{
|
||||
camera.add2y(value);
|
||||
camera->add2y(value);
|
||||
}
|
||||
|
||||
void OpenGLController::addTransZ(double value)
|
||||
{
|
||||
camera.add2z(value);
|
||||
camera->add2z(value);
|
||||
}
|
||||
|
||||
void OpenGLController::updateScene()
|
||||
|
Reference in New Issue
Block a user