summaryrefslogtreecommitdiff
path: root/lib/glbase.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/glbase.cc')
-rw-r--r--lib/glbase.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/glbase.cc b/lib/glbase.cc
index b6d41ef..ebbfe08 100644
--- a/lib/glbase.cc
+++ b/lib/glbase.cc
@@ -8,7 +8,7 @@
#include "config.h"
#endif
-mogltk::glbase::glbase(int w, int h, int flags) throw (GeneralException) : mogltk::base(w, h, flags, 0), twoD(0) {
+mogltk::glbase::glbase(int w, int h, int flags) throw (GeneralException) : mogltk::base(w, h, flags, 0), twoD(0), fovy(60.0) {
SDL_Surface * surface;
mogltk::engine::setup();
@@ -23,8 +23,7 @@ mogltk::glbase::glbase(int w, int h, int flags) throw (GeneralException) : moglt
mogltk::engine::glbase_o = this;
mogltk::engine::base_o = this;
- float ratio = surface->w;
- ratio /= surface->h;
+ ratio = (GLdouble) surface->w / surface->h;
printm(M_INFO, "Video resolution: %dx%dx%d (ratio = %3.2f)\n", surface->w, surface->h, surface->format->BitsPerPixel, ratio);
printm(M_INFO, "\n");
@@ -50,7 +49,7 @@ mogltk::glbase::glbase(int w, int h, int flags) throw (GeneralException) : moglt
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- gluPerspective(60.0, ratio, 1.0, 1024.0);
+ gluPerspective(fovy, ratio, 1.0, 1024.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -145,3 +144,20 @@ void mogltk::glbase::glVertex(GLdouble x, GLdouble y, GLdouble z, GLdouble w) {
glVertex4d(x, y, z, w);
}
+void mogltk::glbase::changeviewport(int x, int y, unsigned int w, unsigned int h) {
+ if ((w == 0) && (h == 0)) {
+ w = GetWidth() - x;
+ h = GetHeight() - y;
+ }
+
+ ratio = (GLdouble) w / h;
+ glViewport(x, y, w, h);
+ if (!engine::base_o->is2D())
+ gluPerspective(fovy, ratio, 1.0, 1024.0);
+}
+
+void mogltk::glbase::changefovy(GLdouble nfoyv) {
+ fovy = nfoyv;
+ if (!engine::base_o->is2D())
+ gluPerspective(fovy, ratio, 1.0, 1024.0);
+}