Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Graphics > OpenGL 3D API > Opengl renderin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 4787 of 5017
Post > Topic >>

Opengl rendering

by shreejanshrestha@[EMAIL PROTECTED] Jun 10, 2008 at 03:43 AM

I have an application which uses OpenGL. In that application I have a
function which will use gl* functions to render. The rendering is done
only when the size of the view,

orientation, position of the object in the view and/or camera changes.
Otherwise I rely on the swapbuffer mechanism to display the correct
image, hoping that the backbuffer is always

ok. But this didn't work for all hardware. Currently I have been
fixing the problem by rendering at OnDraw() message. But this fix is
not a proper solution for my application as I have

lots of object with so many polygons.

I also have set PFD_SWAP_COPY while choosing PIXELFORMATDESCRIPTOR for
open gl, so that the back buffer will always have the correct rendered
image. But this also in vain, as I

came to know that PFD_SWAP_COPY is just a hint to hardware driver.

Currently I want to try this logic:
1) render using gl functions
2) capture the back buffer
3) use the captured back buffer to draw using windows GDI from OnDraw

I cannot think about any solution so any help or reference will be
highly appreciated.

Following is the code snippet which I want to use:

// gl functions to render
void COGLView::Draw3DObject()
{
	wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC);

	// gl functions
	gluLookAt(....);
	glBegin(....);
	//......
	//......
	//......
	glEnd();

	glFinish();
	SwapBuffer(m_pDC->GetSafeHdc(), m_hRC);
}

void COGLView::OnDraw(CDC* pDC)
{
	wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC);

	// swap the buffer for allowing windows to draw in this view
	SwapBuffers(m_pDC->GetSafeHdc());

	glFinish();
}

void COGLView::OnSize(UINT nType, int cx, int cy)
{
	CView::OnSize(nType, cx, cy);

	if(cx <= 0 || cy <= 0)
	{
		return;
	}

	wglMakeCurrent(m_pDC->GetSafeHdc(), m_hRC);

	glView****t(0, 0, cx, cy);

	SetProjection();

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	wglMakeCurrent(NULL, NULL);

	Draw3DObject();
}

void COGLView::OnMouseMove(UINT nFlags, CPoint point)
{
	BOOL bRefresh = TRUE;

	// free rotation in opengl x and y axes
	m_cCamera3D.RotateX(0.5 * (m_pntCursor.x - point.x));
	m_cCamera3D.RotateY(0.5 * (m_pntCursor.y - point.y));

	if(bRefresh == TRUE)
	{
		Draw3DObject();
	}
}

But have been fixing by calling Draw3DObject() at OnDraw().
 




 8 Posts in Topic:
Opengl rendering
shreejanshrestha@[EMAIL P  2008-06-10 03:43:42 
Re: Opengl rendering
fungus <openglMYSOCKS@  2008-06-10 04:58:27 
Re: Opengl rendering
shreejanshrestha@[EMAIL P  2008-06-10 10:05:29 
Re: Opengl rendering
Andy V <nobody@[EMAIL   2008-06-10 20:46:29 
Re: Opengl rendering
shreejanshrestha@[EMAIL P  2008-06-10 22:03:56 
Re: Opengl rendering
Andy V <nobody@[EMAIL   2008-06-11 19:03:38 
Re: Opengl rendering
fungus <openglMYSOCKS@  2008-06-11 18:28:14 
Re: Opengl rendering
fungus <openglMYSOCKS@  2008-06-11 18:30:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 3:47:53 CST 2008.