[osg-users] aspect ratio resize

ghb ghb0430 at hotmail.com
Wed Jul 9 03:00:05 PDT 2008


Hi everyone:I had build a simple OSG program with visual studio2005.net and rendered the scene to a win32 window.I want to change the aspect ratio when the size of the win32 window was  resized, but it can't work correctly.
 
Here is some code in my program and the whole project has been attached.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
    ....................
   case WM_CREATE:      gOSG = new COsg(hWnd);      gOSG->InitOSG(filename);      /* gThreadHandle = (HANDLE)_beginthread(&COsg::Render, 0, gOSG); */   break;    case WM_SIZE:   {    int cx = LOWORD(lParam);    int cy = HIWORD(lParam);
    double asp = double(cx)/double(cy);    gOSG->getViewer()->getCamera()->setViewport(0,0,cx,cy);    gOSG->getViewer()->getCamera()->setProjectionMatrixAsPerspective(30.0f,asp,0.1f,10000.0f);
    }    break;
   ........................ }
 
int APIENTRY WinMain(HINSTANCE hInstance,                     HINSTANCE hPrevInstance,                     LPTSTR    lpCmdLine,                     int       nCmdShow)
{
................
 while(!done)         // Loop That Runs While done=FALSE {       if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?       {            if (msg.message==WM_QUIT)    // Have We Received A Quit Message?            {               done=TRUE;       // If So done=TRUE            }            else         // If Not, Deal With Window Messages            {               TranslateMessage(&msg);    // Translate The Message               DispatchMessage(&msg);    // Dispatch The Message            }       }       else          // If There Are No Messages      {            gOSG->getViewer()->frame();       } }
........................
 
}
 
As is shown above, I didn't create a new thread for rendering and just made it in the main loop.
 
 
 
_________________________________________________________________
MSN史诗巨片横空出世,精彩抢先看!
http://im.msn.cn/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080709/cdc9f4f2/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Project2.rar
Type: application/octet-stream
Size: 49686 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080709/cdc9f4f2/attachment-0002.obj>


More information about the osg-users mailing list