Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC resizing OpenGL

MFC resizing OpenGL

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionphpcomgraphics
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zqueezy
    wrote on last edited by
    #1

    hey guys this is more of a MFC-question than OpenGL I guess, that's why I put it here. I integrated an OpenGL-control in my MFC-proggy, like from here: (http://www.codeguru.com/cpp/g-m/opengl/article.php/c5583) all works fine, except that "glViewport(0, 0, width, height);" makes no difference and I cannot get the correct aspect ratio for my OpenGL-viewport (Except my app is squared). When the app is resized I call the Resize-function of my opengl-class which looks like this void COpenGL::Resize(int posx, int posy, int width, int height) { if (height==0) height=1; // prevent division by zero } this->SetWindowPos(&CWnd::wndBottom, posx, posy, width, height, NULL); glViewport(0,0,(GLsizei)width,( GLsizei)height); //<-- problem here glMatrixMode(GL_PROJECTION); glLoadIdentity (); gluPerspective(45.0f,(float)width/((float)height),0.1f,100.0f); glMatrixMode(GL_MODELVIEW); } The first part resizes OpenGL-Control... works The second part should resize the viewport (camera/aspect-ratio)... those commands work fine in a console app using only glut. any idea? thx in advance zqueezy

    Z 1 Reply Last reply
    0
    • Z zqueezy

      hey guys this is more of a MFC-question than OpenGL I guess, that's why I put it here. I integrated an OpenGL-control in my MFC-proggy, like from here: (http://www.codeguru.com/cpp/g-m/opengl/article.php/c5583) all works fine, except that "glViewport(0, 0, width, height);" makes no difference and I cannot get the correct aspect ratio for my OpenGL-viewport (Except my app is squared). When the app is resized I call the Resize-function of my opengl-class which looks like this void COpenGL::Resize(int posx, int posy, int width, int height) { if (height==0) height=1; // prevent division by zero } this->SetWindowPos(&CWnd::wndBottom, posx, posy, width, height, NULL); glViewport(0,0,(GLsizei)width,( GLsizei)height); //<-- problem here glMatrixMode(GL_PROJECTION); glLoadIdentity (); gluPerspective(45.0f,(float)width/((float)height),0.1f,100.0f); glMatrixMode(GL_MODELVIEW); } The first part resizes OpenGL-Control... works The second part should resize the viewport (camera/aspect-ratio)... those commands work fine in a console app using only glut. any idea? thx in advance zqueezy

      Z Offline
      Z Offline
      zqueezy
      wrote on last edited by
      #2

      so guys, sorry for posting that early... the answer is: the definition has to be done before drawing not in resizing... donnu why, but that works fine... but thanx for this cool forum

      H 1 Reply Last reply
      0
      • Z zqueezy

        so guys, sorry for posting that early... the answer is: the definition has to be done before drawing not in resizing... donnu why, but that works fine... but thanx for this cool forum

        H Offline
        H Offline
        Hans Dietrich
        wrote on last edited by
        #3

        Glad you found the solution. Come back and visit us again.

        Best wishes, Hans


        [CodeProject Forum Guidelines] [How To Ask A Question] [My Articles]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups