Changeset 1773
- Timestamp:
- Aug 18, 2012, 9:26:03 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gpu/framebuffer.cpp
r1761 r1773 45 45 46 46 #if defined USE_D3D9 47 LPDIRECT3DTEXTURE9 m_texture; 48 LPDIRECT3DSURFACE9 m_surface, m_back_surface; 47 49 #elif defined _XBOX 48 50 #else … … 61 63 m_data->m_size = size; 62 64 #if defined USE_D3D9 || defined _XBOX 63 /* FIXME: not implemented on Direct3D */ 65 if (FAILED(g_d3ddevice->CreateTexture(size.x, size.y, 1, 66 D3DUSAGE_RENDERTARGET, 67 D3DFMT_R8G8B8, D3DPOOL_DEFAULT, 68 &m_data->m_texture, NULL))) 69 Abort(); 70 if (FAILED(m_data->m_texture->GetSurfaceLevel(0, &m_data->m_surface))) 71 Abort(); 64 72 #else 65 73 # if GL_VERSION_1_1 … … 125 133 { 126 134 #if defined USE_D3D9 || defined _XBOX 135 m_data->m_surface->Release(); 136 m_data->m_texture->Release(); 127 137 #else 128 138 # if GL_VERSION_1_1 || GL_ES_VERSION_2_0 … … 140 150 } 141 151 142 intFrameBuffer::GetTexture() const152 ShaderTexture FrameBuffer::GetTexture() const 143 153 { 154 ShaderTexture ret; 144 155 #if defined USE_D3D9 || defined _XBOX 145 ret urn 0;156 ret.m_flags = (uint64_t)(uintptr_t)m_data->m_texture; 146 157 #else 147 ret urnm_data->m_texture;158 ret.m_flags = m_data->m_texture; 148 159 #endif 160 return ret; 149 161 } 150 162 … … 152 164 { 153 165 #if defined USE_D3D9 || defined _XBOX 166 if (FAILED(g_d3ddevice->GetRenderTarget(0, &m_data->m_back_surface))) 167 Abort(); 168 if (FAILED(g_d3ddevice->SetRenderTarget(0, m_data->m_surface))) 169 Abort(); 154 170 #else 155 171 # if GL_VERSION_1_1 || GL_ES_VERSION_2_0 … … 164 180 { 165 181 #if defined USE_D3D9 || defined _XBOX 182 if (FAILED(g_d3ddevice->SetRenderTarget(0, m_data->m_back_surface))) 183 Abort(); 166 184 #else 167 185 # if GL_VERSION_1_1 || GL_ES_VERSION_2_0 -
trunk/src/gpu/framebuffer.h
r1455 r1773 28 28 ~FrameBuffer(); 29 29 30 int GetTexture() const; 31 void Clear(vec4 color); 32 void Clear(vec4 color, float depth); 30 ShaderTexture GetTexture() const; 33 31 34 32 void Bind(); -
trunk/src/gpu/shader.cpp
r1690 r1773 537 537 } 538 538 539 void Shader::Set Texture(ShaderUniform const &uni, int id, int index)540 { 541 #if defined USE_D3D9 || defined _XBOX 542 /* FIXME: unimplemented */539 void Shader::SetUniform(ShaderUniform const &uni, ShaderTexture tex, int index) 540 { 541 #if defined USE_D3D9 || defined _XBOX 542 g_d3ddevice->SetTexture(index, (LPDIRECT3DTEXTURE9)tex.m_flags); 543 543 #elif !defined __CELLOS_LV2__ 544 544 glActiveTexture(GL_TEXTURE0 + index); 545 545 //glEnable(GL_TEXTURE_2D); 546 glBindTexture(GL_TEXTURE_2D, id);546 glBindTexture(GL_TEXTURE_2D, (int)tex.m_flags); 547 547 SetUniform(uni, index); 548 548 #else -
trunk/src/gpu/shader.h
r1452 r1773 47 47 }; 48 48 49 struct ShaderTexture 50 { 51 friend class Shader; 52 friend class FrameBuffer; 53 54 public: 55 inline ShaderTexture() : m_flags(0) {} 56 57 private: 58 uint64_t m_flags; 59 }; 60 49 61 class ShaderData; 50 62 … … 71 83 void SetUniform(ShaderUniform const &uni, mat3 const &m); 72 84 void SetUniform(ShaderUniform const &uni, mat4 const &m); 73 74 /* FIXME: this should be called SetUniform, too, but we need a new 75 * type to represent textures. */ 76 void SetTexture(ShaderUniform const &uni, int id, int index); 85 void SetUniform(ShaderUniform const &uni, ShaderTexture tex, int index); 77 86 78 87 void Bind() const; -
trunk/tools/neercs/video/render.cpp
r1771 r1773 417 417 { 418 418 shader_simple->Bind(); 419 shader_simple->Set Texture(shader_simple_texture, fbo_output->GetTexture(), n);419 shader_simple->SetUniform(shader_simple_texture, fbo_output->GetTexture(), n); 420 420 fs_quad(); 421 421 shader_simple->Unbind(); … … 858 858 fbo_ping->Bind(); 859 859 shader_remanency->Bind(); 860 shader_remanency->Set Texture(shader_remanency_source, fbo_back->GetTexture(), 0);861 shader_remanency->Set Texture(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);860 shader_remanency->SetUniform(shader_remanency_source, fbo_back->GetTexture(), 0); 861 shader_remanency->SetUniform(shader_remanency_buffer, fbo_buffer->GetTexture(), 1); 862 862 shader_remanency->SetUniform(shader_remanency_mix, remanency); 863 863 fs_quad(); … … 871 871 fbo_ping->Bind(); 872 872 shader_remanency->Bind(); 873 shader_remanency->Set Texture(shader_remanency_source, fbo_front->GetTexture(), 0);874 shader_remanency->Set Texture(shader_remanency_buffer, fbo_buffer->GetTexture(), 1);873 shader_remanency->SetUniform(shader_remanency_source, fbo_front->GetTexture(), 0); 874 shader_remanency->SetUniform(shader_remanency_buffer, fbo_buffer->GetTexture(), 1); 875 875 shader_remanency->SetUniform(shader_remanency_mix, buffer); 876 876 fs_quad(); … … 889 889 fbo_blur_h->Bind(); 890 890 shader_blur_h->Bind(); 891 shader_blur_h->Set Texture(shader_blur_h_texture, fbo_back->GetTexture(), 0);891 shader_blur_h->SetUniform(shader_blur_h_texture, fbo_back->GetTexture(), 0); 892 892 shader_blur_h->SetUniform(shader_blur_h_radius, glow_large / screen_size.x); 893 893 fs_quad(); … … 897 897 fbo_blur_v->Bind(); 898 898 shader_blur_v->Bind(); 899 shader_blur_v->Set Texture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);899 shader_blur_v->SetUniform(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 900 900 shader_blur_v->SetUniform(shader_blur_v_radius, glow_large / screen_size.y); 901 901 fs_quad(); … … 905 905 fbo_blur_h->Bind(); 906 906 shader_blur_h->Bind(); 907 shader_blur_h->Set Texture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);907 shader_blur_h->SetUniform(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0); 908 908 shader_blur_h->SetUniform(shader_blur_h_radius, glow_small / screen_size.x); 909 909 fs_quad(); … … 913 913 fbo_blur_v->Bind(); 914 914 shader_blur_v->Bind(); 915 shader_blur_v->Set Texture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);915 shader_blur_v->SetUniform(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); 916 916 shader_blur_v->SetUniform(shader_blur_v_radius, glow_small / screen_size.y); 917 917 fs_quad(); … … 921 921 fbo_front->Bind(); 922 922 shader_glow->Bind(); 923 shader_glow->Set Texture(shader_glow_glow, fbo_blur_v->GetTexture(), 0);924 shader_glow->Set Texture(shader_glow_source, fbo_back->GetTexture(), 1);923 shader_glow->SetUniform(shader_glow_glow, fbo_blur_v->GetTexture(), 0); 924 shader_glow->SetUniform(shader_glow_source, fbo_back->GetTexture(), 1); 925 925 shader_glow->SetUniform(shader_glow_mix, glow_mix); 926 926 fs_quad(); … … 941 941 fbo_ping->Bind(); 942 942 shader_blur_h->Bind(); 943 shader_blur_h->Set Texture(shader_blur_h_texture, fbo_front->GetTexture(), 0);943 shader_blur_h->SetUniform(shader_blur_h_texture, fbo_front->GetTexture(), 0); 944 944 shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x); 945 945 fs_quad(); … … 949 949 fbo_front->Bind(); 950 950 shader_blur_v->Bind(); 951 shader_blur_v->Set Texture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);951 shader_blur_v->SetUniform(shader_blur_v_texture, fbo_ping->GetTexture(), 0); 952 952 shader_blur_v->SetUniform(shader_blur_v_radius, blur / screen_size.y); 953 953 fs_quad(); … … 960 960 // shader postfx 961 961 shader_postfx->Bind(); 962 shader_postfx->Set Texture(shader_postfx_texture, fbo_front->GetTexture(), 0);962 shader_postfx->SetUniform(shader_postfx_texture, fbo_front->GetTexture(), 0); 963 963 shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size); 964 964 shader_postfx->SetUniform(shader_postfx_time, fx_angle); -
trunk/tools/neercs/video/text-render.cpp
r1706 r1773 151 151 void TextRender::Blit(ivec2 pos, ivec2 size) 152 152 { 153 /* FIXME: this is ugly! But we will get rid of it when we 154 * do the Direct3D port, so don't worry too much. */ 155 ShaderTexture t = m_fbo->GetTexture(); 156 uint64_t const &x = *(uint64_t const *)&t; 157 153 158 glDisable(GL_BLEND); 154 159 glEnable(GL_TEXTURE_2D); 155 glBindTexture(GL_TEXTURE_2D, m_fbo->GetTexture());160 glBindTexture(GL_TEXTURE_2D, (int)x); 156 161 glColor3f(1.0f, 1.0f, 1.0f); 157 162 … … 170 175 glEnd(); 171 176 } 177 -
trunk/tutorial/08_fbo.cpp
r1771 r1773 103 103 m_shader->Bind(); 104 104 m_shader->SetUniform(m_uni_flag, 1.f); 105 m_shader->Set Texture(m_uni_texture, m_fbo->GetTexture(), 0);105 m_shader->SetUniform(m_uni_texture, m_fbo->GetTexture(), 0); 106 106 m_vdecl->SetStream(m_vbo, m_coord); 107 107 m_vdecl->Bind();
Note: See TracChangeset
for help on using the changeset viewer.