Bläddra i källkod

gpu: create the ShaderTexture class, replace Shader::SetTexture with a

Shader::SetUniform override, and implement most of the FBO code for
the Direct3D backend.
master
Sam Hocevar 12 år sedan
förälder
incheckning
ee34d7d3ca
2 ändrade filer med 22 tillägg och 16 borttagningar
  1. +14
    -14
      neercs/video/render.cpp
  2. +8
    -2
      neercs/video/text-render.cpp

+ 14
- 14
neercs/video/render.cpp Visa fil

@@ -416,7 +416,7 @@ void fs_quad()
void draw_shader_simple(FrameBuffer *fbo_output, int n)
{
shader_simple->Bind();
shader_simple->SetTexture(shader_simple_texture, fbo_output->GetTexture(), n);
shader_simple->SetUniform(shader_simple_texture, fbo_output->GetTexture(), n);
fs_quad();
shader_simple->Unbind();
}
@@ -857,8 +857,8 @@ void Render::Draw3D()
// shader remanency
fbo_ping->Bind();
shader_remanency->Bind();
shader_remanency->SetTexture(shader_remanency_source, fbo_back->GetTexture(), 0);
shader_remanency->SetTexture(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);
shader_remanency->SetUniform(shader_remanency_source, fbo_back->GetTexture(), 0);
shader_remanency->SetUniform(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);
shader_remanency->SetUniform(shader_remanency_mix, remanency);
fs_quad();
shader_remanency->Unbind();
@@ -870,8 +870,8 @@ void Render::Draw3D()
// save previous fbo
fbo_ping->Bind();
shader_remanency->Bind();
shader_remanency->SetTexture(shader_remanency_source, fbo_front->GetTexture(), 0);
shader_remanency->SetTexture(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);
shader_remanency->SetUniform(shader_remanency_source, fbo_front->GetTexture(), 0);
shader_remanency->SetUniform(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);
shader_remanency->SetUniform(shader_remanency_mix, buffer);
fs_quad();
shader_remanency->Unbind();
@@ -888,7 +888,7 @@ void Render::Draw3D()
// shader blur horizontal
fbo_blur_h->Bind();
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_texture, fbo_back->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_radius, glow_large / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
@@ -896,7 +896,7 @@ void Render::Draw3D()
// shader blur vertical
fbo_blur_v->Bind();
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_radius, glow_large / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
@@ -904,7 +904,7 @@ void Render::Draw3D()
// shader blur horizontal
fbo_blur_h->Bind();
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_radius, glow_small / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
@@ -912,7 +912,7 @@ void Render::Draw3D()
// shader blur vertical
fbo_blur_v->Bind();
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_radius, glow_small / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
@@ -920,8 +920,8 @@ void Render::Draw3D()
// shader glow
fbo_front->Bind();
shader_glow->Bind();
shader_glow->SetTexture(shader_glow_glow, fbo_blur_v->GetTexture(), 0);
shader_glow->SetTexture(shader_glow_source, fbo_back->GetTexture(), 1);
shader_glow->SetUniform(shader_glow_glow, fbo_blur_v->GetTexture(), 0);
shader_glow->SetUniform(shader_glow_source, fbo_back->GetTexture(), 1);
shader_glow->SetUniform(shader_glow_mix, glow_mix);
fs_quad();
shader_glow->Unbind();
@@ -940,7 +940,7 @@ void Render::Draw3D()
// shader blur horizontal
fbo_ping->Bind();
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_front->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_texture, fbo_front->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
@@ -948,7 +948,7 @@ void Render::Draw3D()
// shader blur vertical
fbo_front->Bind();
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_radius, blur / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
@@ -959,7 +959,7 @@ void Render::Draw3D()
{
// shader postfx
shader_postfx->Bind();
shader_postfx->SetTexture(shader_postfx_texture, fbo_front->GetTexture(), 0);
shader_postfx->SetUniform(shader_postfx_texture, fbo_front->GetTexture(), 0);
shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size);
shader_postfx->SetUniform(shader_postfx_time, fx_angle);
shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);


+ 8
- 2
neercs/video/text-render.cpp Visa fil

@@ -150,9 +150,14 @@ void TextRender::Render()

void TextRender::Blit(ivec2 pos, ivec2 size)
{
/* FIXME: this is ugly! But we will get rid of it when we
* do the Direct3D port, so don't worry too much. */
ShaderTexture t = m_fbo->GetTexture();
uint64_t const &x = *(uint64_t const *)&t;

glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_fbo->GetTexture());
glBindTexture(GL_TEXTURE_2D, (int)x);
glColor3f(1.0f, 1.0f, 1.0f);

vec2 tc = (vec2)m_canvas_size * m_font_size / m_fbo_size;
@@ -168,4 +173,5 @@ void TextRender::Blit(ivec2 pos, ivec2 size)
glTexCoord2f(tc.x, 0.0f);
glVertex2i(pos.x + size.x, pos.y + size.y);
glEnd();
}
}


Laddar…
Avbryt
Spara