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

OpenGL MFC

Scheduled Pinned Locked Moved C / C++ / MFC
databasegraphicsc++game-devdata-structures
2 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 an openGL window within an MFC dialog. I've connected to MSAccess as my DB where i pick coordinates which i use to draw GL_LINES and GL_QUADS. I've checked out my code and it seems to be working correctly but nothing shows on the GLWindow. Wne i hardcode values ... it shows sometimes and other times it doesn't. Might anyone know what i'm doing wrong here? Any help would be highly appreciated... My code for connecting and drawing is as follows: /**************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)) { throw _com_error(hr); } //Create a pointer to a Recordset in memory hr = rsObjectsPtr.CreateInstance(__uuidof(ADODB::Recordset)); if (FAILED(hr)) { throw _com_error(hr); } //Set Connection properties cnSURMPtr2->CursorLocation = ADODB::adUseClient; //Generate connection string _bstr_t dbLocation(L""); dbLocation = (L".\\SURM.mdb"); //Open the connection cnSURMPtr2->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ dbLocation +";Persist Security Info=False","","",ADODB::adConnectUnspecified); //Open Objects recordset rsObjectsPtr->Open("SELECT * from Objects", cnSURMPtr2.GetInterfacePtr(), ADODB::adOpenDynamic, ADODB::adLockOptimistic, ADODB::adCmdText); //Read from First to Last Record to load into GLWindow if(!rsObjectsPtr->ADOEOF){ if(rsObjectsPtr->GetRecordCount()>0){ //Move to the FIRST record //rsObjectsPtr->MoveFirst(); while (rsObjectsPtr->ADOEOF == false){ //Code to load cordinates in GLWindow _variant_t myCoordinates; //Read from DB myCoordinates = rsObjectsPtr->GetCollect(L"Coordinates"); //myCoordinates = rsObjectsPtr->Fields->GetItem(L"Coordinates")->GetValue(); if(myCoordinates.vt != VT_NULL){ //Change to String and pick each vertex coordinate CString myStrCoords; myStrCoords = static_cast(_bstr_t(myCoordinates.bstrVal)); //if(myStrCoords != ""){ //Determine array size int myArraySize = (myStrCoords.GetLength()/9); //CString singleCoord[myArraySize] = new CString[myArraySize]; CString *singleCoord = new CString[myArraySize]; int tokenCounter = 0; //Put each token into an array element while(myStrCoords.GetLength()>=9

    Steve EcholsS 1 Reply Last reply
    0
    • B braveheartkenya

      I have an openGL window within an MFC dialog. I've connected to MSAccess as my DB where i pick coordinates which i use to draw GL_LINES and GL_QUADS. I've checked out my code and it seems to be working correctly but nothing shows on the GLWindow. Wne i hardcode values ... it shows sometimes and other times it doesn't. Might anyone know what i'm doing wrong here? Any help would be highly appreciated... My code for connecting and drawing is as follows: /**************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)) { throw _com_error(hr); } //Create a pointer to a Recordset in memory hr = rsObjectsPtr.CreateInstance(__uuidof(ADODB::Recordset)); if (FAILED(hr)) { throw _com_error(hr); } //Set Connection properties cnSURMPtr2->CursorLocation = ADODB::adUseClient; //Generate connection string _bstr_t dbLocation(L""); dbLocation = (L".\\SURM.mdb"); //Open the connection cnSURMPtr2->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ dbLocation +";Persist Security Info=False","","",ADODB::adConnectUnspecified); //Open Objects recordset rsObjectsPtr->Open("SELECT * from Objects", cnSURMPtr2.GetInterfacePtr(), ADODB::adOpenDynamic, ADODB::adLockOptimistic, ADODB::adCmdText); //Read from First to Last Record to load into GLWindow if(!rsObjectsPtr->ADOEOF){ if(rsObjectsPtr->GetRecordCount()>0){ //Move to the FIRST record //rsObjectsPtr->MoveFirst(); while (rsObjectsPtr->ADOEOF == false){ //Code to load cordinates in GLWindow _variant_t myCoordinates; //Read from DB myCoordinates = rsObjectsPtr->GetCollect(L"Coordinates"); //myCoordinates = rsObjectsPtr->Fields->GetItem(L"Coordinates")->GetValue(); if(myCoordinates.vt != VT_NULL){ //Change to String and pick each vertex coordinate CString myStrCoords; myStrCoords = static_cast(_bstr_t(myCoordinates.bstrVal)); //if(myStrCoords != ""){ //Determine array size int myArraySize = (myStrCoords.GetLength()/9); //CString singleCoord[myArraySize] = new CString[myArraySize]; CString *singleCoord = new CString[myArraySize]; int tokenCounter = 0; //Put each token into an array element while(myStrCoords.GetLength()>=9

      Steve EcholsS Offline
      Steve EcholsS Offline
      Steve Echols
      wrote on last edited by
      #2

      The only thing I can think of off the top of my head is the default winding in opengl is counter-clockwise, so you need to draw your quad vertexes in that order, unless you change it to clockwise with glFrontFace(GL_CW). delete this; * poof! *

      • S
        50 cups of coffee and you know it's on!
        Code, follow, or get out of the way.
      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