glReadPixels

Started by
2 comments, last by maxell120 21 years, 7 months ago
i''m trying to find out what is the equivalence of glReadPixels, glReadBuffer(GL_BACK),and glReadBuffer(GL_FRONT) in Directx? glReadPixels(0,0,lpbih->biWidth,lpbih->biHeight,GL_BGR_EXT,GL_UNSIGNED_BYTE,bmBits); i''m trying to conver this line to directx...plss help me! thnks .jm.
if you see me running, try and catch me!!
Advertisement
You''ll have to lock the texture you''re trying to access, and read out the data at the pointer it returns to you, and unlock again.

IDirect3DTexture8::LockRect() I think, or something along those lines. See SDK.

- JQ
Full Speed Games. Coming soon.
~phil
here is the sample code that i have which is in opengl...
what i would like to do is to be able to convert this in directx. suggestions anyone?

you could see the complete code of this at :
http://www.codeproject.com/audio/avigenerator.asp


  void CMainFrame::OnAvigenerationGenerate() {	int i;	CAVIGenerator AviGen;	LPBITMAPINFOHEADER lpbih;	BYTE* bmBits;		CGL2AviView* pView=(CGL2AviView*)GetActiveView();	AviGen.SetRate(10);					// set 20fps	AviGen.SetBitmapHeader(pView);		// give info about bitmap	AviGen.SetFileName("test.avo");	// retreiving size of image	lpbih=AviGen.GetBitmapHeader();	// allocating memory	bmBits=new BYTE[lpbih->biSizeImage];	VERIFY(AviGen.InitEngine());	// reading back buffer	glReadBuffer(GL_BACK);	for(i=0;i<200;i++)	{		// render frame		pView->DrawGL();		// Copy from OpenGL to buffer		glReadPixels(0,0,lpbih->biWidth,lpbih->biHeight,GL_BGR_EXT,GL_UNSIGNED_BYTE,bmBits); 		// send to avi engine		AviGen.AddFrame(bmBits);	}	// releasing engine and memory	VERIFY(AviGen.ReleaseEngine());	delete[] bmBits;	glReadBuffer(GL_FRONT);}  
if you see me running, try and catch me!!
Are you using D3D 8?

If so, you can get the display backbuffer as a IDirect3DSurface8 by calling IDirect3DDevice8::GetBackBuffer().

You can get the front buffer similarly:

IDirect3DDevice8::GetFrontBuffer

There''s nothing that''s quite the same as glReadPixels, you need to parse the buffer pixel data yourself. Generally you''ll call IDirect3DSurface8::GetDesc to get the data you need from the surface (pixel format, size, pitch, etc) and use that to pull out specific x/y pixel values or regions.

This topic is closed to new replies.

Advertisement