Jump to content
  • Advertisement

Archived

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

Daniel Toll

PBuffers and pixelformats

This topic is 5556 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

Hi While working on my little engine I want to use pbuffers for offscren rendering to textures... After downloading a few tutorials from NVIDIA and read through a few papers I got to work, trying to implement pbuffers in my shaders... No success... :-( I copy the rendered result to a texture and rendered the result, pitch black! The copy part seems to work... I´ve copied parts of the back-buffer and that worked... But thats no fun... The code in the tutorial works...in the tutorial but not in my framework... My guess is that my framework, containing old code which does not use wglChoosePixelFormatARB, is the one causing me trouble? //Context creation if (!(PixelFormat=ChoosePixelFormat(m_hDC,&pfd))) { } if(!SetPixelFormat(m_hDC,PixelFormat,&pfd)) { // Return FALSE } So what i wonder is if anyone else have had these problems? Or stumbled on a solution? yours...

Share this post


Link to post
Share on other sites
Advertisement
Perhaps this may helps you:

if you want to render directly into a texture you should
do something like this:


hdc = wglGetCurrentDC();
hrc = wglGetCurrentContext();

depth_bits = depthbits;
color_bits = colorbits;
pb_width = width;
pb_height = height;

int format;
int pformat[MAX_PFORMATS];
unsigned int nformats;
int iattributes[2*MAX_ATTRIBS];
float fattributes[2*MAX_ATTRIBS];
int nfattribs = 0;
int niattribs = 0;

memset(iattributes,0,sizeof(int)*2*MAX_ATTRIBS);
memset(fattributes,0,sizeof(float)*2*MAX_ATTRIBS);

iattributes[niattribs ] = WGL_DRAW_TO_PBUFFER_ARB;
iattributes[++niattribs] = true;

iattributes[++niattribs] = WGL_COLOR_BITS_ARB;
iattributes[++niattribs] = color_bits;

iattributes[++niattribs] = WGL_DEPTH_BITS_ARB;
iattributes[++niattribs] = depth_bits;

iattributes[++niattribs] = WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV;
iattributes[++niattribs] = true;


if (!wglChoosePixelFormatARB( hdc, iattributes, fattributes, MAX_PFORMATS, pformat, &nformats))
{
return false;
}

format = pformat[0];

memset(iattributes,0,sizeof(int)*2*MAX_ATTRIBS);
niattribs = 0;

iattributes[niattribs] = WGL_TEXTURE_FORMAT_ARB;
iattributes[++niattribs] = WGL_TEXTURE_RGBA_ARB;

iattributes[++niattribs] = WGL_TEXTURE_TARGET_ARB;
iattributes[++niattribs] = WGL_TEXTURE_RECTANGLE_NV;

iattributes[++niattribs] = WGL_PBUFFER_LARGEST_ARB;
iattributes[++niattribs] = true;

hpbuffer = wglCreatePbufferARB( hdc, format, pb_width, pb_height, iattributes );
if (hpbuffer == 0)
{
return false;
}
pb_hdc = wglGetPbufferDCARB(hpbuffer);
if (pb_hdc == 0)
{
return false;
}
pb_hrc = wglCreateContext(pb_hdc);
if (pb_hrc == 0)
{
return false;
}

if (wglMakeCurrent(hdc, hrc) == FALSE) return false;

if (share)
wglShareLists(hrc, pb_hrc);

wglQueryPbufferARB(hpbuffer, WGL_PBUFFER_WIDTH_ARB, &pb_width);
wglQueryPbufferARB(hpbuffer, WGL_PBUFFER_HEIGHT_ARB, &pb_height);

if (wglMakeCurrent(hdc, hrc) == FALSE) return false;


for more info go to my homepage www.beam.to/panorama -> releases and download the source of my demo "black and white", there are several offsccreen-buffers used

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!