dungeon_crawler

diff prototype/src/renderer.cc @ 20:48cfd351a9be

mrt going on nicely
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 21 Aug 2012 04:57:33 +0300
parents 8a0ae6b4aa9b
children 0588f8a1a351
line diff
     1.1 --- a/prototype/src/renderer.cc	Tue Aug 21 04:29:49 2012 +0300
     1.2 +++ b/prototype/src/renderer.cc	Tue Aug 21 04:57:33 2012 +0300
     1.3 @@ -74,19 +74,18 @@
     1.4  {
     1.5  	int loc;
     1.6  
     1.7 -	static GLenum draw_bufs[] = {
     1.8 -		GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT,
     1.9 -		GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT,
    1.10 -		GL_COLOR_ATTACHMENT4_EXT, GL_COLOR_ATTACHMENT5_EXT,
    1.11 -		GL_COLOR_ATTACHMENT6_EXT, GL_COLOR_ATTACHMENT7_EXT
    1.12 -	};
    1.13 -
    1.14  	// render into the MRT buffers
    1.15  	glBindFramebufferEXT(GL_FRAMEBUFFER, fbo);
    1.16 -	glDrawBuffersARB(MRT_COUNT, draw_bufs);
    1.17  
    1.18  	glUseProgram(mrt_prog);
    1.19 +	if((loc = glGetUniformLocation(mrt_prog, "tex_dif")) != -1) {
    1.20 +		glUniform1i(loc, 0);
    1.21 +	}
    1.22 +	if((loc = glGetUniformLocation(mrt_prog, "tex_norm")) != -1) {
    1.23 +		glUniform1i(loc, 1);
    1.24 +	}
    1.25  	draw_func();
    1.26 +
    1.27  	glUseProgram(0);
    1.28  	glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
    1.29  
    1.30 @@ -160,11 +159,19 @@
    1.31  		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex_xsz, tex_ysz, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
    1.32  
    1.33  		// attach to fbo
    1.34 -		glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D,
    1.35 -				mrt_tex[i], 0);
    1.36 +		glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
    1.37 +				GL_TEXTURE_2D, mrt_tex[i], 0);
    1.38  		CHECKGLERR;
    1.39  	}
    1.40  
    1.41 +	static GLenum draw_bufs[] = {
    1.42 +		GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT,
    1.43 +		GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT,
    1.44 +		GL_COLOR_ATTACHMENT4_EXT, GL_COLOR_ATTACHMENT5_EXT,
    1.45 +		GL_COLOR_ATTACHMENT6_EXT, GL_COLOR_ATTACHMENT7_EXT
    1.46 +	};
    1.47 +	glDrawBuffersARB(MRT_COUNT, draw_bufs);
    1.48 +
    1.49  	glGenRenderbuffersEXT(1, &rbuf_depth);
    1.50  	glBindRenderbufferEXT(GL_RENDERBUFFER, rbuf_depth);
    1.51  	glRenderbufferStorageEXT(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, tex_xsz, tex_ysz);