Mondschein Engine  0.3.0
display_list.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 "gl13/display_list.h"
22 #include "core/camera.h"
23 #include "core/light.h"
24 #include "core/material.h"
25 #include "core/mesh.h"
26 #include <GL/gl.h>
27 #include <cmath>
28 #include <GL/glu.h>
29 
30 using namespace mondschein;
31 using namespace renderer;
32 
33 GL13_Display_List::GL13_Display_List() : displaylist(glGenLists(1))
34 {
35  return;
36 }
37 
38 GL13_Display_List::GL13_Display_List(uint32 _dsp) : displaylist(_dsp)
39 {
40  return;
41 }
42 
43 GL13_Display_List::~GL13_Display_List()
44 {
45  glDeleteLists(displaylist,1);
46  return;
47 }
48 
49 void GL13_Display_List::set_displaylist(uint32 _dsp)
50 {
51  displaylist=_dsp;
52  return;
53 }
54 
55 uint32 GL13_Display_List::get_displaylist() const
56 {
57  return displaylist;
58 }
59 
60 void GL13_Display_List::render() const
61 {
62  if (glIsList(displaylist)) glCallList(displaylist);
63  else
64  {
65  std::string err("Mondschein Engine ERROR: Internal reference is not a valid OpenGL 1.3 compliant display list. ");
66  err+="Exception raised in function\n\t";
67  err+="void mondschein::renderer::GL13_Display_List::render() const";
68  throw boost::enable_current_exception(exception()) << exception_error(err);
69  }
70  return;
71 }