Browse Source

gpu: first shot at a Shader::SetTexture() function.

legacy
Sam Hocevar sam 12 years ago
parent
commit
e5e598bd68
2 changed files with 20 additions and 0 deletions
  1. +16
    -0
      src/gpu/shader.cpp
  2. +4
    -0
      src/gpu/shader.h

+ 16
- 0
src/gpu/shader.cpp View File

@@ -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


+ 4
- 0
src/gpu/shader.h View File

@@ -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;



Loading…
Cancel
Save