Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
C-Fu
OpenGL
Commits
f824f4eb
Commit
f824f4eb
authored
Sep 07, 2016
by
Anakin
Browse files
implement singleton pattern
parent
e7d7bec6
Changes
3
Hide whitespace changes
Inline
Side-by-side
MshViewer/Header/OpenGLController.h
View file @
f824f4eb
...
...
@@ -8,10 +8,13 @@
class
OpenGLController
{
public:
OpenGLController
();
OpenGLController
(
int
oglMajor
,
int
oglMinor
);
static
OpenGLController
&
getInstance
(
int
oglMajor
=
4
,
int
oglMinor
=
5
);
~
OpenGLController
();
private:
OpenGLController
()
{};
OpenGLController
(
int
oglMajor
,
int
oglMinor
);
private:
int
iOglMajorVersion
;
int
iOglMinorVersion
;
...
...
@@ -30,7 +33,7 @@ private:
glm
::
mat4
m4x4Model
;
glm
::
mat4
m4x4MVP
;
Camera
camera
;
Camera
*
camera
;
Object
*
object
;
struct
{
...
...
MshViewer/Source/OpenGlController.cpp
View file @
f824f4eb
...
...
@@ -8,33 +8,33 @@
/////////////////////////////////////////////////////////////////////////
// public constructor/destructor
OpenGLController
::
OpenGLController
()
:
iWidth
(
640
),
iHeight
(
480
),
camera
(
iWidth
,
iHeight
)
OpenGLController
&
OpenGLController
::
getInstance
(
int
oglMajor
,
int
oglMinor
)
{
initDefault
();
processInit
();
static
OpenGLController
instace
(
oglMajor
,
oglMinor
);
return
instace
;
}
OpenGLController
::~
OpenGLController
()
{
glDeleteTextures
(
1
,
&
gluiSamplerID
);
glfwTerminate
();
}
/////////////////////////////////////////////////////////////////////////
// private constructor
OpenGLController
::
OpenGLController
(
int
oglMajor
,
int
oglMinor
)
:
iWidth
(
640
),
iHeight
(
480
),
camera
(
iWidth
,
iHeight
)
iHeight
(
480
)
{
camera
=
new
Camera
(
iWidth
,
iHeight
);
initDefault
();
iOglMajorVersion
=
oglMajor
;
iOglMinorVersion
=
oglMinor
;
processInit
();
}
OpenGLController
::~
OpenGLController
()
{
glDeleteTextures
(
1
,
&
gluiSamplerID
);
glfwTerminate
();
}
/////////////////////////////////////////////////////////////////////////
// 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
()
...
...
MshViewer/main.cpp
View file @
f824f4eb
...
...
@@ -6,7 +6,7 @@
int
main
(
int
argc
,
char
**
argv
)
{
OpenGLController
scene
;
OpenGLController
scene
=
OpenGLController
::
getInstance
()
;
do
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment