diff options
author | pixel <pixel> | 2003-11-14 17:21:14 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-11-14 17:21:14 +0000 |
commit | fae0c2bfe95a122de0f165791690dc18928a931c (patch) | |
tree | 1f8056a480702d72c4f871ad7375a575510bb7ff /lib/glbase.cc | |
parent | d7575bef1e530eac004c973b0384a12561f0bb8b (diff) |
Started working on widgets.
Diffstat (limited to 'lib/glbase.cc')
-rw-r--r-- | lib/glbase.cc | 24 |
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); +} |