Archived

This topic is now archived and is closed to further replies.

glReadPixels

This topic is 5577 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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);
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites