当前位置: 首页>>代码示例>>C++>>正文


C++ OpenCL::setupFromOpenGL方法代码示例

本文整理汇总了C++中msa::OpenCL::setupFromOpenGL方法的典型用法代码示例。如果您正苦于以下问题:C++ OpenCL::setupFromOpenGL方法的具体用法?C++ OpenCL::setupFromOpenGL怎么用?C++ OpenCL::setupFromOpenGL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在msa::OpenCL的用法示例。


在下文中一共展示了OpenCL::setupFromOpenGL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setup

//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(50, 50, 50);
	
	
	// dump everything to console
	ofSetLogLevel(OF_LOG_VERBOSE);
	
	
	// disable vsync (to allow >60fps)
	ofSetVerticalSync(false);
	
	
	// init grabber
	videoGrabber.initGrabber(640, 480);	
	vidWidth	= videoGrabber.getWidth();
	vidHeight	= videoGrabber.getHeight();
	

	// allocate temp buffer
	pixels		= new unsigned char[vidWidth * vidHeight * 4];
	

	// init OpenCL from OpenGL context to enable GL-CL data sharing
	openCL.setupFromOpenGL();
	
	
	// create OpenCL textures and related OpenGL textures
	clImage[0].initWithTexture(vidWidth, vidHeight, GL_RGBA);
	clImage[1].initWithTexture(vidWidth, vidHeight, GL_RGBA);
	

	// load and compile OpenCL program
	openCL.loadProgramFromFile("MSAOpenCL/ImageProcessing.cl");
	
	
	// load kernels
	openCL.loadKernel("msa_boxblur");
	openCL.loadKernel("msa_flipx");
	openCL.loadKernel("msa_flipy");
	openCL.loadKernel("msa_greyscale");
	openCL.loadKernel("msa_invert");
	openCL.loadKernel("msa_threshold");
}
开发者ID:Jornason,项目名称:ofxMSAOpenCL,代码行数:44,代码来源:testApp.cpp

示例2: setup

//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(0, 0, 0);
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetVerticalSync(false);
	
	opencl.setupFromOpenGL();
    
    // create vbo
    glGenBuffersARB(1, &vbo);
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo);
	glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(float2) * NUM_PARTICLES, 0, GL_DYNAMIC_COPY_ARB);
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);

    // init host and CL buffers
    particles.initBuffer(NUM_PARTICLES);
    particlePos.initFromGLObject(vbo, NUM_PARTICLES);

    // init data
	for(int i=0; i<NUM_PARTICLES; i++) {
		Particle &p = particles[i];
		p.vel.set(0, 0);
		p.mass = ofRandom(0.5, 1);		
		particlePos[i].set(ofRandomWidth(), ofRandomHeight());
	}
    
    particles.writeToDevice();
    particlePos.writeToDevice();
	
	
	opencl.loadProgramFromFile("MSAOpenCL/Particle.cl");
	opencl.loadKernel("updateParticle");

	opencl.kernel("updateParticle")->setArg(0, particles.getCLMem());
	opencl.kernel("updateParticle")->setArg(1, particlePos.getCLMem());
	opencl.kernel("updateParticle")->setArg(2, mousePos);
	opencl.kernel("updateParticle")->setArg(3, dimensions);
	
	glPointSize(1);
}
开发者ID:Jornason,项目名称:ofxMSAOpenCL,代码行数:40,代码来源:testApp.cpp

示例3: init

void ofxKinectTracking::init(){
	openCL.setupFromOpenGL();
	
#ifndef NORMAL_CAMERA
	kinect = new ofxKinect();
	kinect->init();
	kinect->setVerbose(true);
	kinect->open();
	
	
	
	//The depth image
	clImage[0].initFromTexture(kinect->getDepthTextureReference(), CL_MEM_READ_ONLY, 0);	
#else
	videoGrabber.initGrabber(640, 480, true);
	clImage[0].initWithTexture(640, 480, GL_LUMINANCE, CL_MEM_READ_ONLY);
	pixels		= new unsigned char[640*480];
	
#endif
	
	//The debug image
	clImage[1].initWithTexture(640, 480, GL_RGBA);
	
	//Intialize the ants buffer
	resetBufferData();
	clAntsBuffer.initBuffer(sizeof(Ant)*NUM_ANTS, CL_MEM_READ_WRITE, ants, true);
	
	//Buffer of shared variables
	sharedVariables[0] = 0;	
	clSharedBuffer.initBuffer(sizeof(int)*1, CL_MEM_READ_WRITE, sharedVariables, true);
	
	openCL.loadProgramFromFile("../../../../../addons/ofxKinectTracking/src/KinectTracking.cl");
	
	openCL.loadKernel("preUpdate");
	openCL.loadKernel("update");
	openCL.loadKernel("postUpdate");
}
开发者ID:HalfdanJ,项目名称:ofxKinectTracking,代码行数:37,代码来源:ofxKinectTracking.cpp

示例4: setup

//--------------------------------------------------------------
void testApp::setup(){
	ofBackground(0, 0, 0);
	ofSetLogLevel(OF_LOG_VERBOSE);
	ofSetVerticalSync(false);
	
#ifdef USE_OPENGL_CONTEXT
	opencl.setupFromOpenGL();
#else
	opencl.setup(CL_DEVICE_TYPE_CPU, 2);
#endif
	
	for(int i=0; i<NUM_PARTICLES; i++) {
		Particle &p = particles[i];
		p.vel.set(0, 0);
		p.mass = ofRandom(0.5, 1);
		particlesPos[i].set(ofRandomWidth(), ofRandomHeight());
	}
	
	glGenBuffersARB(1, vbo);
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo[0]);
	glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(float2) * NUM_PARTICLES, particlesPos, GL_DYNAMIC_COPY_ARB);
	glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
	
	
	opencl.loadProgramFromFile("MSAOpenCL/Particle.cl");
	kernelUpdate = opencl.loadKernel("updateParticle");
	
	
	clMemParticles.initBuffer(sizeof(Particle) * NUM_PARTICLES, CL_MEM_READ_WRITE, particles);
#ifdef USE_OPENGL_CONTEXT
	clMemPosVBO.initFromGLObject(vbo[0]);
#else
	clMemPosVBO.initBuffer(sizeof(Vec2) * NUM_PARTICLES, CL_MEM_READ_WRITE, particlesPos);
#endif
	
	kernelUpdate->setArg(0, clMemParticles.getCLMem());
	kernelUpdate->setArg(1, clMemPosVBO.getCLMem());
	kernelUpdate->setArg(2, mousePos);
	kernelUpdate->setArg(3, dimensions);
	
	glPointSize(1);
}
开发者ID:sheva29,项目名称:oF_exercises,代码行数:43,代码来源:testApp.cpp


注:本文中的msa::OpenCL::setupFromOpenGL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。