zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Video.cpp
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <zeni_graphics.h>
19 
20 #include <Zeni/GLU.h>
21 
22 #include <GLSLANG/ShaderLang.h>
23 
24 #ifdef _WINDOWS
25 #include <WinUser.h>
26 #endif
27 
28 #include <algorithm>
29 #include <iostream>
30 #include <fstream>
31 
32 #include <Zeni/Define.h>
33 
34 #if defined(_DEBUG) && defined(_WINDOWS)
35 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
36 #define new DEBUG_NEW
37 #endif
38 
39 #include <Zeni/Singleton.hxx>
40 
41 namespace Zeni {
42 
43  template class Singleton<Video>;
44 
45  Video * Video::create() {
46  Video * video = 0;
47 
48  File_Ops &fo = get_File_Ops();
49 
50  const String appdata_path = fo.get_appdata_path();
51 
52  const String user_normal = appdata_path + "config/zenilib.xml";
53  const String user_backup = user_normal + ".bak";
54  const String local_normal = "config/zenilib.xml";
55  const String local_backup = local_normal + ".bak";
56 
57  static bool last_resort_taken = false;
58 
59 #ifndef ANDROID
60  try
61 #endif
62  {
63  switch(Video::g_video_mode) {
65 #ifndef DISABLE_GL_SHADER
67  video = new Video_GL_Shader();
68  break;
69 #endif
70 #ifndef DISABLE_DX9
72  video = new Video_DX9();
73  break;
74 #endif
75 #ifndef DISABLE_GL_FIXED
77  video = new Video_GL_Fixed();
78  break;
79 #endif
80  default:
81  throw Video_Init_Failure();
82  }
83  }
84 #ifndef ANDROID
85  catch(Video_Init_Failure &) {
88 
89  if(fo.copy_file(user_backup, user_normal) && fo.delete_file(user_backup)) {
90  std::cerr << '\'' << user_normal << "' backup restored due to initialization failure.\n";
91  Video::preinit_from_file(user_normal);
92  get_Video();
93  }
94  else if(fo.copy_file(local_backup, local_normal) && fo.delete_file(local_backup)) {
95  std::cerr << '\'' << local_normal << "' backup restored due to initialization failure.\n";
96  Video::preinit_from_file(local_normal);
97  get_Video();
98  }
99  else if(!last_resort_taken) {
101 
102  last_resort_taken = true;
103 
104  get_Video();
105  }
106  else
107  throw;
108  }
109 #endif
110 
111  last_resort_taken = false;
112 
113  return video;
114  }
115 
116  Singleton<Video>::Uninit Video::g_uninit;
117  Singleton<Video>::Reinit Video::g_reinit;
118 
120  :
121  m_color(1.0f, 1.0f, 1.0f, 1.0f),
122  m_preview(Matrix4f::Translate(Vector3f(-0.5f, -0.5f, 0.0f)) *
123  Matrix4f::Scale(Vector3f(0.5f, -0.5f, -1.0f)) *
124  Matrix4f::Translate(Vector3f(1.0f, -1.0f, 0.0f))),
125  m_alpha_test(false),
126  m_alpha_function(Video::ZENI_ALWAYS),
127  m_alpha_value(0.0f),
128  m_3d(false)
129  {
130  static bool once = false;
131  if(!once) {
132  once = true;
133  ShInitialize();
134  atexit((void (*)())ShFinalize);
135  }
136 
137  Window::remove_post_reinit(&g_reinit);
138 
139  Window &wr = get_Window();
140 
141  wr.lend_pre_uninit(&g_uninit);
142  wr.lend_post_reinit(&g_reinit);
143  }
144 
146  Window::remove_pre_uninit(&g_uninit);
147  }
148 
150  return Singleton<Video>::get();
151  }
152 
153  void Video::set_2d_view(const std::pair<Point2f, Point2f> &camera2d, const std::pair<Point2i, Point2i> &viewport, const bool &fix_aspect_ratio) {
154  m_3d = false;
155 
156  set_viewport(calculate_viewport(camera2d, viewport, fix_aspect_ratio));
157 
158  const Matrix4f view = Matrix4f::Identity();
159  set_view_matrix(view);
160 
161  const std::pair<Point2i, Point2i> &vp = get_viewport();
163  offset.x *= (camera2d.second.x - camera2d.first.x) / (vp.second.x - vp.first.x);
164  offset.y *= (camera2d.second.y - camera2d.first.y) / (vp.second.y - vp.first.y);
165 
166  const Matrix4f projection = Matrix4f::Orthographic(camera2d.first.x + offset.x,
167  camera2d.second.x + offset.x,
168  camera2d.second.y + offset.y,
169  camera2d.first.y + offset.y,
171  set_projection_matrix(projection);
172  }
173 
174  void Video::set_3d_view(const Camera &camera, const std::pair<Point2i, Point2i> &viewport) {
175  m_3d = true;
176 
177  const Matrix4f view = camera.get_view_matrix();
178  set_view_matrix(view);
179 
180  const Matrix4f projection = camera.get_projection_matrix(viewport);
181  set_projection_matrix(projection);
182 
183  set_viewport(viewport);
184  }
185 
186  void Video::set_backface_culling(const bool &on) {
187  g_backface_culling = on;
188  }
189 
190  void Video::set_vertical_sync(const bool &on) {
191  g_vertical_sync = on;
192  }
193 
194  void Video::set_zwrite(const bool &enabled) {
195  g_zwrite = enabled;
196  }
197 
198  void Video::set_ztest(const bool &enabled) {
199  g_ztest = enabled;
200  }
201 
202  void Video::set_alpha_test(const bool &enabled,
203  const TEST &test,
204  const float &value) {
205  m_alpha_test = enabled;
206  m_alpha_function = test;
207  m_alpha_value = value;
208  }
209 
210  void Video::set_Color(const Color &color) {
211  m_color = color;
212  }
213 
215  g_clear_color = color;
216  }
217 
218  void Video::set_lighting(const bool &on) {
219  g_lighting = on;
220  }
221 
223  g_ambient_lighting = color;
224  }
225 
226  void Video::set_view_matrix(const Matrix4f &view) {
227  m_view = view;
228  }
229 
230  void Video::set_projection_matrix(const Matrix4f &projection) {
231  m_projection = projection;
232  }
233 
234  void Video::set_viewport(const std::pair<Point2i, Point2i> &viewport) {
235  m_viewport = viewport;
236  }
237 
238  void Video::set_viewport(const float &aspect_ratio, const std::pair<Point2i, Point2i> &viewport_) {
239  set_viewport(calculate_viewport(aspect_ratio, viewport_));
240  }
241 
242  std::pair<Point2i, Point2i> Video::calculate_viewport(const std::pair<Point2f, Point2f> &camera2d, const std::pair<Point2i, Point2i> &viewport, const bool &fix_aspect_ratio) {
243  if(fix_aspect_ratio)
244  return calculate_viewport((camera2d.second.x - camera2d.first.x) / (camera2d.second.y - camera2d.first.y), viewport);
245  else
246  return viewport;
247  }
248 
249  std::pair<Point2i, Point2i> Video::calculate_viewport(const float &aspect_ratio, const std::pair<Point2i, Point2i> &viewport_) const {
250  std::pair<Point2i, Point2i> viewport = viewport_;
251 
252  int width = viewport.second.x - viewport.first.x;
253  int height = viewport.second.y - viewport.first.y;
254  const float given_ratio = float(width) / height;
255 
256  if(given_ratio > aspect_ratio) {
257  const int new_width = int(width * aspect_ratio / given_ratio);
258  const int cut_side = (width - new_width) / 2;
259 
260  viewport.first.x += cut_side;
261  viewport.second.x -= cut_side;
262  }
263  else if(aspect_ratio > given_ratio) {
264  const int new_height = int(height * given_ratio / aspect_ratio);
265  const int cut_side = (height - new_height) / 2;
266 
267  viewport.first.y += cut_side;
268  viewport.second.y -= cut_side;
269  }
270 
271  return viewport;
272  }
273 
274  const Light * Video::get_Light(const int &number) const {
275  const Unordered_Map<int, Light>::const_iterator it = g_lights.find(number);
276 
277  if(it != g_lights.end())
278  return &it->second;
279  else
280  return 0;
281  }
282 
283  void Video::set_Light(const int &number, const Light &light) {
284  g_lights[number] = light;
285  }
286 
287  void Video::unset_Light(const int &number) {
288  g_lights.erase(number);
289  }
290 
291  const Fog * Video::get_Fog() const {
292  return g_fog_enabled ? &g_fog : 0;
293  }
294 
295  void Video::set_Fog(const Fog &fog) {
296  g_fog = fog;
297  g_fog_enabled = false;
298  }
299 
301  g_fog_enabled = false;
302  }
303 
306  char c;
307  for(std::ifstream fin(filename.c_str()); fin.get(c); )
308  in += c;
309 
310  std::cerr << "Compiling: " << filename << std::endl;
311  const char * const in_ptr = in.c_str();
312  if(ShCompile(compiler, &in_ptr, 1, SH_OBJECT_CODE | SH_VALIDATE)) {
313  size_t len;
314  ShGetInfo(compiler, SH_OBJECT_CODE_LENGTH, &len);
315  Zeni::String out(len - 1, '\0');
316  ShGetObjectCode(compiler, const_cast<char *>(out.c_str()));
317  std::cerr << "Result:" << std::endl << out;
318  return out;
319  }
320 
322  }
323 
325  g_video_mode = vm;
326  }
327 
328  void Video::preinit_multisampling(const int &multisampling) {
329  g_multisampling = multisampling;
330  }
331 
332  void Video::preinit_vertical_sync(const bool &vertical_sync) {
333  g_vertical_sync = vertical_sync;
334  }
335 
337  XML_Document file(filename);
338  preinit_from_file(file);
339  }
340 
342  XML_Element_c zenilib = file["Zenilib"];
343  XML_Element_c video = zenilib["Video"];
344 
345 #ifndef ANDROID
347 #endif
348 
349  const String api = video["API"].to_string();
350 
352 #ifndef DISABLE_GL_SHADER
353  api == "OpenGL Shader" ? Video::ZENI_VIDEO_GL_SHADER :
354 #endif
355 #ifndef DISABLE_DX9
356  api == "Direct3D 9" || api == "DX9" ? Video::ZENI_VIDEO_DX9 :
357 #endif
358 #ifndef DISABLE_GL_FIXED
359  api == "OpenGL Fixed" || api == "OpenGL" ? Video::ZENI_VIDEO_GL_FIXED :
360 #endif
362  preinit_multisampling(video["Multisampling"].to_int());
363  preinit_vertical_sync(video["Vertical_Sync"].to_bool());
364  }
365 
366  void Video::change_resolution(const Point2i &resolution) {
367  Window &wr = get_Window();
368 
369  if(wr.get_width() == resolution.x && wr.get_height() == resolution.y)
370  return;
371 
372  destroy();
373 
374  try {
375  preinit_from_file(get_File_Ops().get_appdata_path() + "config/zenilib.xml");
376  }
377  catch(XML_Load_Failure &) {
378  preinit_from_file("config/zenilib.xml");
379  }
380 
381 #ifndef ANDROID
382  wr.alert_window_resized(resolution);
383 #endif
384 
385  get();
386  }
387 
388 #ifndef ANDROID
389  void Video::save(const bool &backup) {
390  File_Ops &fo = get_File_Ops();
391 
392  // Initialize paths
393 
394  const String appdata_path = fo.get_appdata_path();
395 
396  const String user_normal = appdata_path + "config/zenilib.xml";
397  const String user_backup = user_normal + ".bak";
398  const String local_normal = "config/zenilib.xml";
399  const String local_backup = local_normal + ".bak";
400 
401  // Create file
402 
404  if(!file.try_load(user_normal))
405  file.load(local_normal);
406 
407  XML_Element zenilib = file["Zenilib"];
408  XML_Element textures = zenilib["Textures"];
409  XML_Element video = zenilib["Video"];
410 
411  textures["Anisotropy"].set_int(Textures::get_anisotropic_filtering());
412  textures["Bilinear_Filtering"].set_bool(Textures::get_bilinear_filtering());
413  textures["Mipmapping"].set_bool(Textures::get_mipmapping());
414 
415  video["API"].set_string(
416 #ifndef DISABLE_GL_SHADER
417  g_video_mode == Video::ZENI_VIDEO_GL_SHADER ? "OpenGL Shader" :
418 #endif
419 #ifndef DISABLE_DX9
420  g_video_mode == Video::ZENI_VIDEO_DX9 ? "Direct3D 9" :
421 #endif
422 #ifndef DISABLE_GL_FIXED
423  g_video_mode == Video::ZENI_VIDEO_GL_FIXED ? "OpenGL Fixed" :
424 #endif
425  "Disabled");
426 
427  video["Full_Screen"].set_bool(Window::is_full_screen());
428  video["Multisampling"].set_int(g_multisampling);
429  video["Resolution"]["Width"].set_int(Window::get_width());
430  video["Resolution"]["Height"].set_int(Window::get_height());
431  video["Vertical_Sync"].set_bool(g_vertical_sync);
432 
433  // User-specific backup and save
434 
435  bool user_save = false;
436  if(fo.create_directory(appdata_path) &&
437  fo.create_directory(appdata_path + "config/"))
438  {
439  if(backup)
440  fo.copy_file(user_normal, user_backup);
441 
442  user_save = file.try_save(user_normal);
443  }
444 
445  // Local backup and save
446 
447  if(backup) {
448  if(user_save)
449  fo.copy_file(user_normal, local_backup);
450  else
451  fo.copy_file(local_normal, local_backup);
452  }
453 
454  file.try_save(local_normal);
455  }
456 
457  bool Video::revert() {
458  File_Ops &fo = get_File_Ops();
459 
460  const String appdata_path = fo.get_appdata_path();
461 
462  const String user_normal = appdata_path + "config/zenilib.xml";
463  const String user_backup = user_normal + ".bak";
464  const String local_normal = "config/zenilib.xml";
465  const String local_backup = local_normal + ".bak";
466 
467  bool reverted = false;
468 
469  try {
470  preinit_from_file(user_normal);
471  get_Video();
472  reverted = true;
473  }
474  catch(Video_Init_Failure &) {
475  }
476 
477  if(!reverted && fo.copy_file(user_backup, user_normal) && fo.delete_file(user_backup)) {
478  std::cerr << '\'' << user_normal << "' backup restored due to initialization failure.\n";
479  try {
480  Video::preinit_from_file(user_normal);
481  get_Video();
482  reverted = true;
483  }
484  catch(Video_Init_Failure &) {
485  }
486  }
487 
488  if(!reverted && fo.copy_file(local_backup, local_normal) && fo.delete_file(local_backup)) {
489  std::cerr << '\'' << local_normal << "' backup restored due to initialization failure.\n";
490  try {
491  Video::preinit_from_file(local_normal);
492  get_Video();
493  reverted = true;
494  }
495  catch(Video_Init_Failure &) {
496  }
497  }
498 
499  if(!reverted) {
500  std::cerr << '\'' << local_normal << "' backup restored due to initialization failure.\n";
502  get_Video();
503  reverted = true;
504  }
505 
506  save(false);
507 
508  return true;
509  }
510 
513 
514  Textures::set_texturing_mode(0, false, false);
515 
516 #if !defined(DISABLE_GL_FIXED)
517  g_video_mode = Video::ZENI_VIDEO_GL_FIXED;
518 #elif !defined(DISABLE_DX9)
519  g_video_mode = Video::ZENI_VIDEO_DX9;
520 #elif !defined(DISABLE_GL_SHADER)
521  g_video_mode = Video::ZENI_VIDEO_GL_SHADER;
522 #else
523  g_video_mode = Video::ZENI_VIDEO_ANY;
524 #endif
525 
526  g_vertical_sync = false;
527  }
528 
530 #if !defined(DISABLE_GL) && !defined(REQUIRE_GL_ES)
531  std::cerr << "OpenGL : " << Zeni::gluErrorString(glGetError()) << std::endl;
532 #endif
533  }
534 #endif
535 
536  Video::VIDEO_MODE Video::g_video_mode = Video::ZENI_VIDEO_ANY;
537  bool Video::g_backface_culling = false;
538  bool Video::g_lighting = false;
539  Color Video::g_ambient_lighting = Color(1.0f, 1.0f, 1.0f, 1.0f);
540  Unordered_Map<int, Light> Video::g_lights;
541  Fog Video::g_fog;
542  bool Video::g_fog_enabled = false;
543  Color Video::g_clear_color = Color(1.0f, 0.0f, 0.0f, 0.0f);
544  bool Video::g_normal_interp = false;
545  bool Video::g_vertical_sync = false;
546  int Video::g_multisampling = 0;
547  bool Video::g_zwrite = true;
548  bool Video::g_ztest = true;
549 
550 }
An Abstraction of a Light.
Definition: Light.h:57
virtual void set_lighting(const bool &on=true)=0
Set lighting on/off.
Definition: Video.cpp:218
String to_string() const
Get the contained string.
Definition: XML.cpp:99
static const int & get_width()
Get the size of the window.
Definition: Window.hxx:33
virtual void set_vertical_sync(const bool &on)=0
Set vertical_sync on/off.
Definition: Video.cpp:190
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint GLint GLint j2 GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar GLenum light
Definition: SDL_glfuncs.h:144
GLuint color
Definition: glew.h:7185
COMPILER_EXPORT int ShCompile(const ShHandle handle, const char *const shaderStrings[], size_t numStrings, int compileOptions)
Definition: ShaderLang.cpp:176
Camera / Point of View.
Definition: Camera.h:49
The Video Rendering Singleton.
Definition: Video.h:71
GLclampf f
Definition: glew.h:3390
static void change_resolution(const Point2i &resolution)
Definition: Video.cpp:366
virtual void set_view_matrix(const Matrix4f &view)=0
Set the view Matrix4f.
Definition: Video.cpp:226
virtual void set_clear_Color(const Color &color)=0
Set the blank background color.
Definition: Video.cpp:214
const std::pair< Point2i, Point2i > & get_viewport() const
Get the viewport.
Definition: Video.hxx:135
virtual void unset_Fog()=0
Unset Fog.
Definition: Video.cpp:300
static bool revert()
Restore previously saved options; Returns true if successful.
Definition: Video.cpp:457
void * ShHandle
Definition: ShaderLang.h:255
GLenum GLsizei const GLuint GLboolean enabled
Definition: glew.h:2538
const Light * get_Light(const int &number) const
Get pointer to Light, or 0 if no such Light.
Definition: Video.cpp:274
bool try_load(const String &filename)
Definition: XML.cpp:314
virtual void set_Light(const int &number, const Light &light)=0
Set a particular Light.
Definition: Video.cpp:283
static int get_anisotropic_filtering()
Check the current level of anisotropy.
Definition: Textures.hxx:40
VIDEO_MODE
Definition: Video.h:96
GLuint in
Definition: glew.h:10672
static bool copy_file(const String &from, const String &to)
Copy a file from one filepath to another.
Definition: File_Ops.cpp:264
FILE * file
Definition: visualinfo.c:88
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:293
const char * c_str() const
Definition: String.cpp:467
#define ZENI_2D_FAR
Definition: Define.h:73
GLenum GLsizei len
Definition: glew.h:7035
virtual void set_zwrite(const bool &enabled)=0
Enable or disable writing to the Z-Buffer.
Definition: Video.cpp:194
String compile_glsles_shader(const String &filename, const ShHandle &compiler)
Compile an OpenGL ES shader to GLSL/HLSL.
Definition: Video.cpp:304
static void remove_post_reinit(Event::Handler *const &handler)
void lend_post_reinit(Event::Handler *const &handler)
Definition: Singleton.hxx:76
void lend_pre_uninit(Event::Handler *const &handler)
Definition: Singleton.hxx:56
static void completely_destroy()
void set_string(const String &s)
Set the contained string.
Definition: XML.cpp:216
Matrix4f get_projection_matrix(const std::pair< Point2i, Point2i > &viewport) const
Equivalent to gluPerspective + tunnel_vision_factor.
Definition: Camera.hxx:76
static void set_failsafe_defaults()
Set failsafe default options.
Definition: Video.cpp:511
virtual ~Video()=0
Definition: Video.cpp:145
A Featureful 3-Space Vector Class.
Definition: Vector3f.h:58
static void preinit_multisampling(const int &multisampling=0)
Set a multisampling value.
Definition: Video.cpp:328
static void remove_pre_uninit(Event::Handler *const &handler)
virtual void set_ztest(const bool &enabled)=0
Enable or disable testing of the Z-Buffer.
Definition: Video.cpp:198
virtual void set_ambient_lighting(const Color &color)=0
Set ambient lighting on/off.
Definition: Video.cpp:222
int
Definition: SDL_systhread.c:37
An Abstraction of Fog.
Definition: Fog.h:47
EGLSurface EGLint EGLint EGLint width
Definition: eglext.h:293
virtual void set_3d_view(const Camera &camera, const std::pair< Point2i, Point2i > &viewport=std::make_pair(Point2i(), get().get_render_target_size()))=0
Set a 3D view for a viewport.
Definition: Video.cpp:174
#define ZENI_2D_NEAR
Definition: Define.h:72
static bool create_directory(const String &directory_path)
Create a directory if it doesn&#39;t already exist; It is not considered an error if it already exists...
Definition: File_Ops.cpp:231
static const bool & is_full_screen()
Determine whether the window is windowed or full screen.
Definition: Window.hxx:54
const GLfloat * c
Definition: glew.h:14913
static TYPE & get()
Definition: Singleton.hxx:31
void set_bool(const bool &b)
Set the contained string as a boolean.
Definition: XML.cpp:200
static Matrix4f Orthographic(const float &left, const float &right, const float &bottom, const float &top, const float &near, const float &far)
Similar to gluOrtho.
Definition: Matrix4f.hxx:89
COMPILER_EXPORT int ShFinalize()
Definition: ShaderLang.cpp:100
A class to open an XML file and manage the root node.
Definition: XML.h:111
virtual void set_Color(const Color &color)=0
Set the current color.
Definition: Video.cpp:210
void load(const String &filename)
Definition: XML.cpp:270
virtual void set_2d_view(const std::pair< Point2f, Point2f > &camera2d, const std::pair< Point2i, Point2i > &viewport=std::make_pair(Point2i(), get().get_render_target_size()), const bool &fix_aspect_ratio=false)=0
Set a 2D view for a viewport.
Definition: Video.cpp:153
static void save(const bool &backup=true)
Save options.
Definition: Video.cpp:389
static void preinit_vertical_sync(const bool &vertical_sync=false)
Set vertical_sync to true.
Definition: Video.cpp:332
COMPILER_EXPORT void ShGetObjectCode(const ShHandle handle, char *objCode)
Definition: ShaderLang.cpp:267
virtual void set_Fog(const Fog &fog)=0
Set Fog.
Definition: Video.cpp:295
void alert_window_resized(const Point2i &resolution)
Tell Window that it has been resized.
Definition: Window.cpp:498
Window & get_Window()
Get access to the singleton.
Definition: Window.cpp:392
virtual void set_projection_matrix(const Matrix4f &projection)=0
Set the projection Matrix4f.
Definition: Video.cpp:230
A node in an XML tree, possibly containing useful data.
Definition: XML.h:86
virtual void set_viewport(const std::pair< Point2i, Point2i > &viewport=std::make_pair(Point2i(), get().get_render_target_size()))=0
Set the viewport.
Definition: Video.cpp:234
String get_appdata_path()
Get the path that should be used for user-modifiable storage.
Definition: File_Ops.cpp:223
std::pair< Point2i, Point2i > calculate_viewport(const std::pair< Point2f, Point2f > &camera2d, const std::pair< Point2i, Point2i > &viewport, const bool &fix_aspect_ratio)
Calculate the viewport.
Definition: Video.cpp:242
static void preinit_from_file(const String &filename)
Set rendering options from a file.
Definition: Video.cpp:336
#define glGetError
Definition: gl_mangle.h:643
EGLSurface EGLint void ** value
Definition: eglext.h:301
GLintptr offset
Definition: glew.h:1668
COMPILER_EXPORT void ShGetInfo(const ShHandle handle, ShShaderInfo pname, size_t *params)
Definition: ShaderLang.cpp:194
static const int & get_height()
Get the height of the window.
Definition: Window.hxx:37
GLsizei const GLuint * textures
Definition: glew.h:4751
static Matrix4f Identity()
Definition: Matrix4f.hxx:52
static void set_texturing_mode(const int &anisotropic_filtering_, const bool &bilinear_filtering_, const bool &mipmapping_)
Check to see if Textures is set to use lazy loading if possible.
Definition: Textures.cpp:104
const GLubyte * gluErrorString(GLenum error)
Definition: GLU.cpp:26
virtual void set_backface_culling(const bool &on)=0
Set backface culling on/off.
Definition: Video.cpp:186
COMPILER_EXPORT int ShInitialize()
Definition: ShaderLang.cpp:91
Video & get_Video()
Get access to the singleton.
Definition: Video.cpp:149
void set_int(const int &i)
Set the contained string as an integer.
Definition: XML.cpp:204
static void preinit_video_mode(const VIDEO_MODE &vm=ZENI_VIDEO_ANY)
Set which rendering engine to use.
Definition: Video.cpp:324
static bool get_mipmapping()
Check if mipmapping is in use.
Definition: Textures.hxx:32
A Featureful 4-Space Matrix Class.
Definition: Matrix4f.h:47
Matrix4f get_view_matrix() const
Equivalent to gluLookAt + tunnel_vision_factor.
Definition: Camera.hxx:72
virtual Point2f get_pixel_offset() const =0
Get the pixel offset in the 2d view.
static void set_failsafe_defaults()
Set failsafe default options.
Definition: Window.cpp:423
virtual void set_alpha_test(const bool &enabled, const TEST &test=ZENI_ALWAYS, const float &value=0.0f)=0
Set the alpha test.
Definition: Video.cpp:202
File_Ops & get_File_Ops()
Get access to the singleton.
Definition: File_Ops.cpp:118
virtual void unset_Light(const int &number)=0
Unset a particular Light.
Definition: Video.cpp:287
static bool get_bilinear_filtering()
Check if bilinear filtering is in use.
Definition: Textures.hxx:28
bool try_save()
Definition: XML.cpp:332
A 2D Point represented with floats.
Definition: Coordinate.h:98
const Fog * get_Fog() const
Get pointer to current Fog, or 0 if no Fog.
Definition: Video.cpp:291
static void preinit_from_xml(const XML_Element_c &video)
Set rendering options from an XML data structure.
Definition: Window.cpp:417
The Window Management Singleton.
Definition: Window.h:53
#define false
Definition: ftrandom.c:50
Color.
Definition: Color.h:41
static bool delete_file(const String &file_path)
Delete a file.
Definition: File_Ops.cpp:255
static void print_errors()
Print any errors that may have occurred.
Definition: Video.cpp:529
A 2D Point represented with integers.
Definition: Coordinate.h:85