clray

diff src/clray.cc @ 39:980bc07be868

Implemented OpenGL/OpenCL interop, and removed the texture copy
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 27 Aug 2010 18:30:09 +0100
parents a218551293ad
children 1bcbb53b3505
line diff
     1.1 --- a/src/clray.cc	Fri Aug 27 02:22:08 2010 +0100
     1.2 +++ b/src/clray.cc	Fri Aug 27 18:30:09 2010 +0100
     1.3 @@ -11,6 +11,7 @@
     1.4  #include "rt.h"
     1.5  #include "matrix.h"
     1.6  #include "scene.h"
     1.7 +#include "ocl.h"
     1.8  
     1.9  void cleanup();
    1.10  void disp();
    1.11 @@ -31,6 +32,7 @@
    1.12  static bool dbg_show_obj = true;
    1.13  
    1.14  static Scene scn;
    1.15 +static unsigned int tex;
    1.16  
    1.17  int main(int argc, char **argv)
    1.18  {
    1.19 @@ -102,11 +104,6 @@
    1.20  	glutMouseFunc(mouse);
    1.21  	glutMotionFunc(motion);
    1.22  
    1.23 -	if(!init_renderer(xsz, ysz, &scn)) {
    1.24 -		return 1;
    1.25 -	}
    1.26 -	atexit(cleanup);
    1.27 -
    1.28  	unsigned int *test_pattern = new unsigned int[xsz * ysz];
    1.29  	for(int i=0; i<ysz; i++) {
    1.30  		for(int j=0; j<xsz; j++) {
    1.31 @@ -114,15 +111,24 @@
    1.32  		}
    1.33  	}
    1.34  
    1.35 -	/*glGenTextures(1, &tex);
    1.36 -	glBindTexture(GL_TEXTURE_2D, tex);*/
    1.37 +	glGenTextures(1, &tex);
    1.38 +	glBindTexture(GL_TEXTURE_2D, tex);
    1.39  	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
    1.40  	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
    1.41  	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    1.42  	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    1.43 -	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F_ARB, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_pattern);
    1.44 +	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, xsz, ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, test_pattern);
    1.45  	delete [] test_pattern;
    1.46  
    1.47 +	if(!init_opencl()) {
    1.48 +		return 1;
    1.49 +	}
    1.50 +
    1.51 +	if(!init_renderer(xsz, ysz, &scn, tex)) {
    1.52 +		return 1;
    1.53 +	}
    1.54 +	atexit(cleanup);
    1.55 +
    1.56  	glutMainLoop();
    1.57  	return 0;
    1.58  }