source: trunk/src/gpu/shader.h @ 1214

Last change on this file since 1214 was 1214, checked in by sam, 8 years ago

win32: the uniform handling code was completely broken; we now properly
retrieve the constant's register index in the description table. This also
allows us to use a single uniform handle for both the vertex and pixel
shaders in a PS3 Cg program.

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11//
12// The Shader class
13// ----------------
14//
15
16#if !defined __LOL_SHADER_H__
17#define __LOL_SHADER_H__
18
19#include <stdint.h>
20
21namespace lol
22{
23
24struct ShaderUniform
25{
26    friend class Shader;
27
28public:
29    ShaderUniform() : flags(0) {}
30
31private:
32    uintptr_t frag, vert;
33    /* FIXME: do we really need this to indicate which locations are valid? */
34    uint32_t flags;
35};
36
37class ShaderData;
38
39class Shader
40{
41public:
42    static Shader *Create(char const *vert, char const *frag);
43    static void Destroy(Shader *shader);
44
45    int GetAttribLocation(char const *attr) const;
46
47    ShaderUniform GetUniformLocation(char const *uni) const;
48    void SetUniform(ShaderUniform const &uni, float f);
49    void SetUniform(ShaderUniform const &uni, vec2 const &v);
50    void SetUniform(ShaderUniform const &uni, vec3 const &v);
51    void SetUniform(ShaderUniform const &uni, vec4 const &v);
52    void SetUniform(ShaderUniform const &uni, mat4 const &m);
53
54    void Bind() const;
55
56protected:
57    Shader(char const *vert, char const *frag);
58    ~Shader();
59
60private:
61    ShaderData *data;
62};
63
64} /* namespace lol */
65
66#endif // __LOL_SHADER_H__
67
Note: See TracBrowser for help on using the repository browser.