Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pbuffer/GLUT/Cg



I have some more information that might solve my problem (with your help if I am lucky):

I am using Glut.
I have created a pbuffer.
I can write to the pbuffer and from the pbuffer to the screen using the fixed pipeline.


I can also write to the screen using a pixel shader (ARB)
However, I cannot write to the pbuffer using the shader. For example, the following code, that
writes to the pbuffer, clears the pbuffer screen and fills it with red (which eventually appears on the screen).
However, the shader, which changes the color from red to yellow, has no effect. Yet, when I simply change
the current context from pbuffer to screen, the shader works as it should and the background red color is
overwritten.


This suggests to me that somehow, the pbuffer context must be active when certain aspects of the shader
are defined, although I have not seen this documented anywhere. Any thoughts on the matter? Thanks.
--------





void Advection::drawToPBuffer(CGLContextObj ctx, CGLContextObj screen, CGLPBufferObj pbuffer, int texNb)
{
glDisable(GL_DEPTH_TEST);


   // The pbuffer is cleared to red, but the shader does not write to the
   // pbuffer. I can use (successfully) the pbuffer as a texture

   glClearColor(1.,0.,0.,1.);
   glClear(GL_COLOR_BUFFER_BIT);

   CG::enable_fp();
   p_initExp.bind();

   glCallList(quad_list);
   CG::disable_fp();

   glFlush();
}
------
Shader:

//----------------------------------------------------------------------
float4 initExp(float2 tc : TEXCOORD0) // [N,N] on nvidia
: COLOR
{
float x = 0.5; //float4 color = float4(1.,x,1.,1.0);
float4 color = float4(.7,1.,0.,1);
return color;
}
//----------------------------------------------------------------------
float4 rewireExp(float2 tc : TEXCOORD0,
uniform sampler2D acc_noise) : COLOR
{ float4 acc = tex2D(acc_noise, tc); // orig
float3 color = acc.xyz / 1.0;
//color = float3(0.,1.,.2) / 1.0;
return float4(color,1.);
}
//----------------------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden


This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.