Click here to Skip to main content
15,900,598 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: what's the use of this? Pin
Nibu babu thomas5-Mar-06 18:12
Nibu babu thomas5-Mar-06 18:12 
AnswerRe: what's the use of this? Pin
Michael Dunn5-Mar-06 18:27
sitebuilderMichael Dunn5-Mar-06 18:27 
Questionto anyone who can explain further...thank you in advance Pin
not insane yet!5-Mar-06 17:25
not insane yet!5-Mar-06 17:25 
AnswerRe: to anyone who can explain further...thank you in advance Pin
Nibu babu thomas5-Mar-06 17:30
Nibu babu thomas5-Mar-06 17:30 
AnswerRe: to anyone who can explain further...thank you in advance Pin
Divyang Mithaiwala5-Mar-06 17:50
Divyang Mithaiwala5-Mar-06 17:50 
Questionproblem in a program code Pin
ashira khera5-Mar-06 17:16
ashira khera5-Mar-06 17:16 
QuestionRe: problem in a program code Pin
David Crow6-Mar-06 3:06
David Crow6-Mar-06 3:06 
Answerhow to replace first half with reversed 2nd half Pin
ashira khera6-Mar-06 8:19
ashira khera6-Mar-06 8:19 
QuestionRe: how to replace first half with reversed 2nd half Pin
David Crow6-Mar-06 8:37
David Crow6-Mar-06 8:37 
QuestionProgram hangs when focused... Pin
the_augy5-Mar-06 15:27
the_augy5-Mar-06 15:27 
AnswerRe: Here's some more information Pin
the_augy5-Mar-06 21:46
the_augy5-Mar-06 21:46 
AnswerYour urgent query... Pin
BadJerry8-Jan-07 1:47
BadJerry8-Jan-07 1:47 
QuestionProgramming Tutor Pin
VegasMalone5-Mar-06 14:45
VegasMalone5-Mar-06 14:45 
AnswerRe: Programming Tutor Pin
John R. Shaw5-Mar-06 16:17
John R. Shaw5-Mar-06 16:17 
QuestionExtracting numbers from a year Pin
Titan905-Mar-06 13:05
Titan905-Mar-06 13:05 
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 

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.