From e5e598bd68df1ced5d2ac455b823464006d1a60a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 11 Jun 2012 21:21:36 +0000 Subject: [PATCH] gpu: first shot at a Shader::SetTexture() function. --- src/gpu/shader.cpp | 16 ++++++++++++++++ src/gpu/shader.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/gpu/shader.cpp b/src/gpu/shader.cpp index 953252d5..f44e6ceb 100644 --- a/src/gpu/shader.cpp +++ b/src/gpu/shader.cpp @@ -517,6 +517,22 @@ void Shader::SetUniform(ShaderUniform const &uni, mat4 const &m) #endif } +void Shader::SetTexture(ShaderUniform const &uni, int id, int index) +{ + if (id == -1) + return; +#if defined USE_D3D9 || defined _XBOX + /* FIXME: unimplemented */ +#elif !defined __CELLOS_LV2__ + glActiveTexture(GL_TEXTURE0 + index); + //glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, id); + SetUniform(uni, index); +#else + /* FIXME: unimplemented */ +#endif +} + void Shader::Bind() const { #if defined USE_D3D9 || defined _XBOX diff --git a/src/gpu/shader.h b/src/gpu/shader.h index 5441bed3..03ef8127 100644 --- a/src/gpu/shader.h +++ b/src/gpu/shader.h @@ -71,6 +71,10 @@ public: void SetUniform(ShaderUniform const &uni, mat3 const &m); void SetUniform(ShaderUniform const &uni, mat4 const &m); + /* FIXME: this should be called SetUniform, too, but we need a new + * type to represent textures. */ + void SetTexture(ShaderUniform const &uni, int id, int index); + void Bind() const; void Unbind() const;