dungeon_crawler

changeset 62:f71381c9e245

gamo to xristo
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 25 Sep 2012 06:59:11 +0300
parents 4472ef41a209
children 7f52d6310317
files prototype/src/renderer.cc prototype/src/renderer.h prototype/src/renderer_deferred.cc prototype/src/renderer_multipass.cc
diffstat 4 files changed, 32 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/prototype/src/renderer.cc	Tue Sep 25 06:37:56 2012 +0300
     1.2 +++ b/prototype/src/renderer.cc	Tue Sep 25 06:59:11 2012 +0300
     1.3 @@ -44,6 +44,20 @@
     1.4  	height = ysz;
     1.5  }
     1.6  
     1.7 +void Renderer::render_pre(const Level *level) const
     1.8 +{
     1.9 +	glEnable(GL_FOG);
    1.10 +	glFogi(GL_FOG_MODE, GL_LINEAR);
    1.11 +	glFogf(GL_FOG_START, 3.0f);
    1.12 +	glFogf(GL_FOG_END, 6.0f);
    1.13 +	// TODO level->draw_pre();
    1.14 +}
    1.15 +
    1.16 +void Renderer::render_post(const Level *level) const
    1.17 +{
    1.18 +	level->draw_post();
    1.19 +}
    1.20 +
    1.21  
    1.22  // ---- fallback forward renderer ----
    1.23  FwdRenderer::FwdRenderer()
    1.24 @@ -86,17 +100,14 @@
    1.25  {
    1.26  	glPushAttrib(GL_ENABLE_BIT);
    1.27  	glEnable(GL_LIGHTING);
    1.28 -	glEnable(GL_FOG);
    1.29 -	glFogi(GL_FOG_MODE, GL_LINEAR);
    1.30 -	glFogf(GL_FOG_START, 3.0f);
    1.31 -	glFogf(GL_FOG_END, 6.0f);
    1.32 +
    1.33 +	render_pre(level);
    1.34  
    1.35  	glUseProgram(sdrprog);
    1.36 +	level->draw();
    1.37 +	glUseProgram(0);
    1.38  
    1.39 -	level->draw();
    1.40 -
    1.41 -	glUseProgram(0);
    1.42 -	level->draw_post();
    1.43 +	render_post(level);
    1.44  
    1.45  	glPopAttrib();
    1.46  }
     2.1 --- a/prototype/src/renderer.h	Tue Sep 25 06:37:56 2012 +0300
     2.2 +++ b/prototype/src/renderer.h	Tue Sep 25 06:59:11 2012 +0300
     2.3 @@ -18,7 +18,9 @@
     2.4  
     2.5  	virtual void resize(int xsz, int ysz);
     2.6  
     2.7 +	virtual void render_pre(const Level *level) const;
     2.8  	virtual void render(const Level *level) const = 0;
     2.9 +	virtual void render_post(const Level *level) const;
    2.10  };
    2.11  
    2.12  
     3.1 --- a/prototype/src/renderer_deferred.cc	Tue Sep 25 06:37:56 2012 +0300
     3.2 +++ b/prototype/src/renderer_deferred.cc	Tue Sep 25 06:59:11 2012 +0300
     3.3 @@ -132,6 +132,8 @@
     3.4  
     3.5  void DeferredRenderer::render(const Level *level) const
     3.6  {
     3.7 +	render_pre(level);
     3.8 +
     3.9  	// render into the MRT buffers
    3.10  	glUseProgram(mrt_prog);
    3.11  	curr_prog = mrt_prog;
    3.12 @@ -147,6 +149,8 @@
    3.13  
    3.14  	glUseProgram(0);
    3.15  	curr_prog = 0;
    3.16 +
    3.17 +	render_post(level);
    3.18  }
    3.19  
    3.20  void DeferredRenderer::light_pass(const Level *level) const
    3.21 @@ -218,13 +222,12 @@
    3.22  		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, tex_xsz, tex_ysz, 0, GL_RGBA, GL_FLOAT, 0);
    3.23  
    3.24  		// attach to fbo
    3.25 -		GLenum color_att = num_draw_bufs >= MRT_COUNT ? GL_COLOR_ATTACHMENT0 + i : GL_COLOR_ATTACHMENT0;
    3.26 -		glFramebufferTexture2DEXT(GL_FRAMEBUFFER, color_att, GL_TEXTURE_2D,
    3.27 -				mrt_tex[i], 0);
    3.28 +		GLenum color_att = GL_COLOR_ATTACHMENT0 + (num_draw_bufs == MRT_COUNT ? i : 0);
    3.29 +		glFramebufferTexture2DEXT(GL_FRAMEBUFFER, color_att, GL_TEXTURE_2D, mrt_tex[i], 0);
    3.30  		CHECKGLERR;
    3.31  	}
    3.32  
    3.33 -	if(num_draw_bufs >= MRT_COUNT) {
    3.34 +	if(num_draw_bufs == MRT_COUNT) {
    3.35  		static GLenum draw_bufs[] = {
    3.36  			GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT,
    3.37  			GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT,
     4.1 --- a/prototype/src/renderer_multipass.cc	Tue Sep 25 06:37:56 2012 +0300
     4.2 +++ b/prototype/src/renderer_multipass.cc	Tue Sep 25 06:59:11 2012 +0300
     4.3 @@ -74,6 +74,8 @@
     4.4  
     4.5  void MultipassRenderer::render(const Level *level) const
     4.6  {
     4.7 +	render_pre(level);
     4.8 +
     4.9  	// render into the MRT buffers
    4.10  	glBindFramebufferEXT(GL_FRAMEBUFFER, fbo);
    4.11  
    4.12 @@ -94,6 +96,8 @@
    4.13  
    4.14  	glUseProgram(0);
    4.15  	curr_prog = 0;
    4.16 +
    4.17 +	render_post(level);
    4.18  }
    4.19  
    4.20  static unsigned int load_sdr(const char *vfname, const char *pfname)