Mondschein Engine  0.3.0
visual.cpp
1 /* Mondschein Engine is a fast, powerful, and easy-to-use 3D realtime rendering engine.
2  *
3  * Copyright (C) 2009-2013 by Andreas Amereller
4  * E-Mail: andreas.amereller.dev@googlemail.com
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "glfw/visual.h"
22 #include <GL/glfw.h>
23 
24 using namespace mondschein;
25 using namespace display;
26 
27 GLFW_Visual::GLFW_Visual() : Visual(), renderer::Context()
28 {
29  return;
30 }
31 
32 GLFW_Visual::GLFW_Visual(const visual_attribs_t &_dsp,const renderer::context_attribs_t &_c) :
33  Visual(_dsp), renderer::Context(_c)
34 {
35  return;
36 }
37 
38 GLFW_Visual::~GLFW_Visual()
39 {
40  glfwCloseWindow();
41  return;
42 }
43 
45 {
47  renderer::context_attribs_t c=renderer::Context::get_data();
48  glfwOpenWindowHint(GLFW_ACCUM_RED_BITS,c.accum_depth(0));
49  glfwOpenWindowHint(GLFW_ACCUM_GREEN_BITS,c.accum_depth(1));
50  glfwOpenWindowHint(GLFW_ACCUM_BLUE_BITS,c.accum_depth(2));
51  glfwOpenWindowHint(GLFW_ACCUM_ALPHA_BITS,c.accum_depth(3));
52  glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE,GL_TRUE);
53  int32 mode=0;
54  if (dsp.fullscreen) mode=GLFW_FULLSCREEN;
55  else mode=GLFW_WINDOW;
56  glfwOpenWindow(dsp.width,dsp.height,c.color_depth(0),c.color_depth(1),c.color_depth(2),c.color_depth(3),
58  return;
59 }
60 
62 {
63  glfwCloseWindow();
64  init();
65  return;
66 }
67 
69 {
70  glfwSwapBuffers();
71  return;
72 }