Ejemplo n.º 1
0
void cEffect::SetParam(const std::string &lacName, cResourceHandle lParamValue)
{
	CGparameter lParam = cgGetNamedEffectParameter(mEffect, lacName.c_str() );
	if (lParam)
	{
		assert(lParamValue.IsValidHandle() );
		cTexture *lpTexture = (cTexture*)lParamValue.GetResource();
		unsigned luiTextureHandle = lpTexture->GetTextureHandle();
		cgGLSetupSampler(lParam, luiTextureHandle);
	}
}
Ejemplo n.º 2
0
/*-------------------------------------------------------------------------

  -------------------------------------------------------------------------*/
void FilterBox::Draw(float f)
{
  if(!bValid)
    return;
  glPolygonMode( GL_FRONT_AND_BACK, GL_FILL);
  CGbool bRes;
  bRes = cgValidateTechnique(cgTechnique);
  if(!bRes)
  {
    bValid = false;
    const char * pszErrors = NULL;
    fprintf(stderr, "Validation of FilterRect failed");
    fprintf(stderr, "CgFx Parse error : %s", pszErrors);
    const char *listing = cgGetLastListing(cgContext);
    return;
  }
  //
  // intermediate stage : bluring horizontal
  //
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[1]);
  glPushAttrib(GL_VIEWPORT_BIT); 
  glViewport(0,0,bufw,bufh);

  cgGLSetupSampler(srcSampler, textureID[0]);
  cgSetPassState(cgPassFilterH);

  FULLSCRQUAD();

  glPopAttrib();
  //
  // intermediate stage : bluring vertical
  //
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[0]);
  glPushAttrib(GL_VIEWPORT_BIT); 
  glViewport(0,0,bufw,bufh);

  cgGLSetupSampler(srcSampler, textureID[1]);
  cgSetPassState(cgPassFilterV);

  FULLSCRQUAD();

  glPopAttrib();
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
  //
  // Final stage : Blend the final texture to the screen
  //
  cgGLSetupSampler(tempSampler, textureID[0]);

  cgSetPassState(cgPassBlend);
  glBlendColor(f,f,f,f);

  float xoffset = -1.0f + 2.0f*(float)posx/(float)vpw;
  float yoffset = -1.0f + 2.0f*(float)posy/(float)vph;
  float xoffset2 = xoffset + 2.0f*(float)width/(float)vpw;
  float yoffset2 = yoffset + 2.0f*(float)height/(float)vph;

  glBegin(GL_QUADS);
  glTexCoord2f(0,0);
  glVertex4f(xoffset, yoffset, 0,1);
  glTexCoord2f(1,0);
  glVertex4f(xoffset2, yoffset,0,1);
  glTexCoord2f(1,1);
  glVertex4f(xoffset2, yoffset2,0,1);
  glTexCoord2f(0,1);
  glVertex4f(xoffset, yoffset2,0,1);
  glEnd();
  cgResetPassState(cgPassBlend);
}