www.pudn.com > GPUVision_5-13-05-2.zip > DxDyFilter.cpp


 
#include "DxDyFilter.h" 
 
using namespace std; 
 
DxDyFilter::DxDyFilter(CGcontext context) : GenericFilter(context){ 
	assert(cgIsContext(_CGcontext)); 
	cgGLEnableProfile(_fragmentProfile); 
	 
	_program = cgCreateProgramFromFile(_CGcontext, CG_SOURCE, "DxDy.cg", 
										_fragmentProfile, NULL, NULL); 
	if (!cgIsProgramCompiled(_program)) 
		cgCompileProgram(_program); 
 
	_textureParam = cgGetNamedParameter(_program, "texture"); 
	cgGLLoadProgram(_program); 
	cgGLDisableProfile(_fragmentProfile); 
} 
DxDyFilter::~DxDyFilter(){ 
	cgDestroyProgram(this->_program); 
} 
 
 
void DxDyFilter::applyFilter(GPUVision *image1){ 
	bool shouldBind = !image1->IsBound(); 
	if(shouldBind) image1->Begin(); 
	glClear(GL_COLOR_BUFFER_BIT); 
	cgGLBindProgram(_program); 
	cgGLSetTextureParameter(_textureParam, image1->IsReset()?image1->GetTextureID():image1->GetRenderedTextureID()); 
	cgGLEnableTextureParameter(_textureParam);	 
 
	cgGLEnableProfile(_fragmentProfile); 
 
	_DrawFull(image1->GetWidth(), image1->GetHeight()); 
 
	cgGLDisableTextureParameter(_textureParam); 
	cgGLDisableProfile(_fragmentProfile); 
	image1->Flip(); 
	if(shouldBind) image1->End(); 
} 
 
void DxDyFilter::applyFilter(GPUVision *image1, GPUVision *image2){ 
	cout << "DxDyFilter applyFilter 2" << endl; 
	this->GenericFilter::applyFilter(image1,image2); 
}