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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. OpenGL & MFC & setfocus

OpenGL & MFC & setfocus

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialcsharpc++graphics
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.
  • B Offline
    B Offline
    braveheartkenya
    wrote on last edited by
    #1

    I have a program where i have created an openGL window within an MFC Dialog using a tutorial on http://steinsoft.net . I have buttons on the Dialog which i want to use to rotate and move (translate) some objects that i have drawn. I implemented some code from http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10[^] to allow me to move around the objects. The code seems to be almost correct, but there seems to be a problem with the focus, coz something is stealing the focus, and thus the events are not getting executed properly. Could someone please tell me how to get around this. Your help would be highly appreciated Thanks in advance If you need my project to look at it for further clarification, you could post your meail address here and i'll mail it to you...

    F 1 Reply Last reply
    0
    • B braveheartkenya

      I have a program where i have created an openGL window within an MFC Dialog using a tutorial on http://steinsoft.net . I have buttons on the Dialog which i want to use to rotate and move (translate) some objects that i have drawn. I implemented some code from http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=10[^] to allow me to move around the objects. The code seems to be almost correct, but there seems to be a problem with the focus, coz something is stealing the focus, and thus the events are not getting executed properly. Could someone please tell me how to get around this. Your help would be highly appreciated Thanks in advance If you need my project to look at it for further clarification, you could post your meail address here and i'll mail it to you...

      F Offline
      F Offline
      FarPointer
      wrote on last edited by
      #2

      Please post the sample here (Only the Main code) Regards, FarPointer

      B 1 Reply Last reply
      0
      • F FarPointer

        Please post the sample here (Only the Main code) Regards, FarPointer

        B Offline
        B Offline
        braveheartkenya
        wrote on last edited by
        #3

        This is the DrawGLScene() function called by onPaint() void COpenGLControl::DrawGLScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(80.0f,-1.0f,0.0f,0.0f); //GLfloat x_m, y_m, z_m, u_m, v_m; GLfloat xTrans = -xpos; GLfloat zTrans = -zpos; GLfloat yTrans = -walkBias-0.25f; GLfloat sceneRoty = 360.0f - yRotation; glRotatef(lookUpDown,1.0f,0.0f,0.0f); glRotatef(sceneRoty,0.0f,1.0f,0.0f); glTranslatef(xTrans, yTrans, zTrans); /**/ //Turn RIGHT if(myRightButton==true){ //::MessageBox(0,(CString)yRotation,"Turn Right",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY); //glRotatef(yRotation,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis heading -= 10.0f; //0.22f; yRotation = heading; ::SetFocus(m_hWnd); //DrawGLScene(); //::MessageBox(0,(CString)yRotation,"Turn Right",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY); } //Turn LEFT if(myLeftButton==true){ //::MessageBox(0,(CString)yRotation,"Turn Left",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY); heading += 10.0f; //0.22f; yRotation = heading; ::SetFocus(m_hWnd); //::SetFocus(this); //glRotatef(yRotation,0.0f,1.0f,0.0f); // Rotate The Triangle On The Y axis }/**/ if(myUpButton==true){ xpos -= (float)sin(heading*piover180) * 0.05f; //0.05f zpos -= (float)cos(heading*piover180) * 0.05f; if (walkBiasAngle >= 359.0f) { walkBiasAngle = 0.0f; } else { walkBiasAngle+= 10; } walkBias = (float)sin(walkBiasAngle * piover180)/20.0f; ::MessageBox(0,"Moving Forward","Move Forward",MB_OK|MB_ICONINFORMATION |MB_DEFAULT_DESKTOP_ONLY); } if(myDownButton==true){ xpos += (float)sin(heading*piover180) * 0.05f; //0.05f; zpos += (float)cos(heading*piover180) * 0.05f; //0.05f; if (walkBiasAngle <= 1.0f) { walkBiasAngle = 359.0f; } else { walkBiasAngle-= 10; } walkBias = (float)sin(walkBiasAngle * piover180)/20.0f; } if(myPageUpButton==true){ //VK_PRIOR lookUpDown-=20.0f; //z-=0.02f; } if(myPageDownButton==true){ //VK_NEXT lookUpDown+=20.0f; //z+=0.02f; } //*************************** // DRAWING CODE //*************************** /**************DATABASE CONNECTION*************/ /* */ HRESULT hr; CoInitialize(NULL); try{ //Create a pointer to a Connection in memory //ADODB::_ConnectionPtr cnSURMPtr; hr = cnSURMPtr2.CreateInstance(__uuidof(ADODB::Connection)); if (FAILED(hr))

        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