Click here to Skip to main content
15,888,733 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Extracting numbers from a year Pin
Michael Dunn5-Mar-06 13:22
sitebuilderMichael Dunn5-Mar-06 13:22 
AnswerRe: Extracting numbers from a year Pin
PJ Arends5-Mar-06 13:31
professionalPJ Arends5-Mar-06 13:31 
GeneralRe: Extracting numbers from a year Pin
Titan905-Mar-06 15:26
Titan905-Mar-06 15:26 
QuestionUsing .lib vs. .dll Pin
Eikthrynir5-Mar-06 12:12
Eikthrynir5-Mar-06 12:12 
AnswerRe: Using .lib vs. .dll Pin
Jörgen Sigvardsson5-Mar-06 12:44
Jörgen Sigvardsson5-Mar-06 12:44 
GeneralRe: Using .lib vs. .dll Pin
John R. Shaw5-Mar-06 16:08
John R. Shaw5-Mar-06 16:08 
AnswerRe: Using .lib vs. .dll Pin
Tim Smith5-Mar-06 14:05
Tim Smith5-Mar-06 14:05 
QuestionOpenGL MFC Pin
braveheartkenya5-Mar-06 11:14
braveheartkenya5-Mar-06 11:14 
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:
<br />
/**************DATABASE CONNECTION*************/<br />
/*	*/<br />
	HRESULT hr;<br />
	CoInitialize(NULL);<br />
	<br />
	try{<br />
		//Create a pointer to a Connection in memory<br />
		//ADODB::_ConnectionPtr cnSURMPtr;<br />
		hr = cnSURMPtr2.CreateInstance(__uuidof(ADODB::Connection));<br />
		if (FAILED(hr))<br />
		{<br />
			throw _com_error(hr);<br />
		}<br />
		<br />
		//Create a pointer to a Recordset in memory<br />
		hr = rsObjectsPtr.CreateInstance(__uuidof(ADODB::Recordset));<br />
		if (FAILED(hr))<br />
		{<br />
			throw _com_error(hr);<br />
		}<br />
		<br />
		//Set Connection properties<br />
		cnSURMPtr2->CursorLocation = ADODB::adUseClient;<br />
		<br />
		//Generate connection string<br />
		_bstr_t dbLocation(L"");<br />
		dbLocation = (L".\\SURM.mdb");<br />
		<br />
		//Open the connection<br />
		cnSURMPtr2->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ dbLocation +";Persist Security Info=False","","",ADODB::adConnectUnspecified);<br />
<br />
		//Open Objects recordset<br />
		rsObjectsPtr->Open("SELECT * from Objects", cnSURMPtr2.GetInterfacePtr(),<br />
		ADODB::adOpenDynamic, ADODB::adLockOptimistic, ADODB::adCmdText);<br />
		<br />
		//Read from First to Last Record to load into GLWindow<br />
		if(!rsObjectsPtr->ADOEOF){<br />
			if(rsObjectsPtr->GetRecordCount()>0){<br />
				//Move to the FIRST record<br />
				//rsObjectsPtr->MoveFirst();<br />
				while (rsObjectsPtr->ADOEOF == false){<br />
					//Code to load cordinates in GLWindow<br />
					_variant_t myCoordinates;<br />
					<br />
					//Read from DB<br />
					myCoordinates = rsObjectsPtr->GetCollect(L"Coordinates");<br />
					//myCoordinates = rsObjectsPtr->Fields->GetItem(L"Coordinates")->GetValue();<br />
<br />
					if(myCoordinates.vt != VT_NULL){<br />
						//Change to String and pick each vertex coordinate<br />
						CString myStrCoords;<br />
<br />
						myStrCoords = static_cast<char *>(_bstr_t(myCoordinates.bstrVal));<br />
						<br />
						//if(myStrCoords != ""){<br />
						//Determine array size<br />
						int myArraySize = (myStrCoords.GetLength()/9);<br />
						//CString singleCoord[myArraySize] = new CString[myArraySize];<br />
						CString *singleCoord = new CString[myArraySize];<br />
						int tokenCounter = 0;<br />
						<br />
						//Put each token into an array element <br />
						while(myStrCoords.GetLength()>=9){<br />
							singleCoord[tokenCounter] = myStrCoords.Left(9);<br />
							//myStrCoords.TrimLeft(10);<br />
							myStrCoords.Delete(0,10);<br />
							tokenCounter++;<br />
						}<br />
						<br />
						//Draw the LINES or QUADS<br />
						if(tokenCounter<=2){<br />
							//openGLControl.drawLine((string)singleCoord[0],(string)singleCoord[0]);<br />
							//glBegin(GL_LINES);<br />
							drawLine((string)singleCoord[0],(string)singleCoord[0]);<br />
							//drawLine("000000000","000000005");<br />
						}<br />
						else{<br />
							//glBegin(GL_QUADS);<br />
							//openGLControl.drawQuad((string)singleCoord[0],(string)singleCoord[1],(string)singleCoord[2],(string)singleCoord[3]);<br />
							drawQuad((string)singleCoord[0],(string)singleCoord[1],(string)singleCoord[2],(string)singleCoord[3]);<br />
							drawQuad("000001000","000001001","000000001","000000000");<br />
							//drawLine("000000000","000000005");<br />
						}<br />
					}//IF statement end bracket<br />
					//Move to next record if not EOF<br />
					rsObjectsPtr->MoveNext();<br />
				}<br />
				if(rsObjectsPtr->BOF){<br />
					rsObjectsPtr->MoveFirst();<br />
				}<br />
				if(rsObjectsPtr->ADOEOF){<br />
					rsObjectsPtr->MoveLast();<br />
				}<br />
			};<br />
		}<br />
	}<br />
	catch(_com_error &e)<br />
	{<br />
<br />
		AfxMessageBox(static_cast<char *>(e.Description()));<br />
		//ShowWindow(1);<br />
	}<br />
	catch(...)<br />
	{<br />
		//std::cerr << "Unhandled Exception";<br />
		AfxMessageBox("Unhandled Exception");<br />
	};<br />
	<br />
/**/<br />
   //This hard-coded part works only at this point in the code<br />
   drawQuad("000001000","000001001","000000001","000000000");<br />
<br />
   SwapBuffers(dc->m_hDC);<br />
}<br />
<br />

This is the code for drawing the QUAD
<br />
void COpenGLControl::drawQuad(string Coord_A, string Coord_B, string Coord_C, string Coord_D){<br />
	//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br />
	//glLoadIdentity();<br />
	<br />
	//Split Coord_A,B,C,D into x,y,z<br />
/**/<br />
	//Split Coord_A into x,y,z<br />
	//Convert to CString before casting<br />
	float myAx = atof(Coord_A.substr(0,3).c_str());<br />
	float Ax = (myAx/10);<br />
	float myAy = atof(Coord_A.substr(3,3).c_str());<br />
	float Ay = (myAy/10);<br />
	float myAz = atof(Coord_A.substr(6,3).c_str());<br />
	float Az = (myAz/10);<br />
<br />
	//Split Coord_B into x,y,z<br />
	//Convert to CString before casting<br />
	float myBx = atof(Coord_B.substr(0,3).c_str());<br />
	float Bx = (myBx/10);<br />
	float myBy = atof(Coord_B.substr(3,3).c_str());<br />
	float By = (myBy/10);<br />
	float myBz = atof(Coord_B.substr(6,3).c_str());<br />
	float Bz = (myBz/10);<br />
	<br />
	//Split Coord_C into x,y,z<br />
	//Convert to CString before casting<br />
	float myCx = atof(Coord_C.substr(0,3).c_str());<br />
	float Cx = (myCx/10);<br />
	float myCy = atof(Coord_C.substr(3,3).c_str());<br />
	float Cy = (myCy/10);<br />
	float myCz = atof(Coord_C.substr(6,3).c_str());<br />
	float Cz = (myCz/10);<br />
<br />
	//Split Coord_D into x,y,z<br />
	//Convert to CString before casting<br />
	float myDx = atof(Coord_D.substr(0,3).c_str());<br />
	float Dx = (myDx/10);<br />
	float myDy = atof(Coord_D.substr(3,3).c_str());<br />
	float Dy = (myDy/10);<br />
	float myDz = atof(Coord_D.substr(6,3).c_str());<br />
	float Dz = (myDz/10);<br />
/**/<br />
	glBegin(GL_QUADS);<br />
		glColor3f(0.0,1.0,0.0);<br />
/**/		<br />
		glVertex3f(Ax,Ay,Az);<br />
		glVertex3f(Bx,By,Bz);<br />
		glVertex3f(Cx,Cy,Cz);<br />
		glVertex3f(Dx,Dy,Dz);<br />
	glEnd();<br />
}<br />

Thanks in advance...
AnswerRe: OpenGL MFC Pin
Steve Echols5-Mar-06 12:28
Steve Echols5-Mar-06 12:28 
Questionproblem calling NtQuerySystemInformation Pin
gamitech5-Mar-06 8:18
gamitech5-Mar-06 8:18 
QuestionCFileDialog Resource Pin
MON2055-Mar-06 6:26
MON2055-Mar-06 6:26 
AnswerRe: CFileDialog Resource Pin
Naveen5-Mar-06 16:10
Naveen5-Mar-06 16:10 
GeneralRe: CFileDialog Resource Pin
MON2055-Mar-06 20:03
MON2055-Mar-06 20:03 
Question2 classes Pin
Sam 20065-Mar-06 5:08
Sam 20065-Mar-06 5:08 
AnswerRe: 2 classes Pin
darkelv5-Mar-06 5:14
darkelv5-Mar-06 5:14 
AnswerRe: 2 classes Pin
Michael Dunn5-Mar-06 6:20
sitebuilderMichael Dunn5-Mar-06 6:20 
Answersolution Pin
Sam 20065-Mar-06 6:24
Sam 20065-Mar-06 6:24 
GeneralRe: solution Pin
John R. Shaw5-Mar-06 14:30
John R. Shaw5-Mar-06 14:30 
GeneralRe: solution Pin
Divyang Mithaiwala5-Mar-06 17:23
Divyang Mithaiwala5-Mar-06 17:23 
QuestionDisplaying OpenGL terrain in MFC Pin
amanoullah5-Mar-06 4:32
amanoullah5-Mar-06 4:32 
QuestionOverloaded functions in DLL Pin
Eikthrynir5-Mar-06 2:59
Eikthrynir5-Mar-06 2:59 
AnswerRe: Overloaded functions in DLL Pin
Gary R. Wheeler5-Mar-06 3:45
Gary R. Wheeler5-Mar-06 3:45 
AnswerRe: Overloaded functions in DLL Pin
Michael Dunn5-Mar-06 6:25
sitebuilderMichael Dunn5-Mar-06 6:25 
Questioninteger to string? Pin
Pacificat0r5-Mar-06 2:02
Pacificat0r5-Mar-06 2:02 
AnswerRe: integer to string? Pin
Gary R. Wheeler5-Mar-06 2:22
Gary R. Wheeler5-Mar-06 2:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.