3 This file is part of gldbg
4 Copyright © 2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
13 #include "bufferstate.h"
14 #include "gldecoder.h"
15 #include "texturestate.h"
26 union { float x, r, s; };
27 union { float y, g, t; };
28 union { float z, b, p; };
29 union { float w, a, q; };
35 Tracks OpenGL state based on the command stream. This class is essentially a
36 (partial) OpenGL implementation in itself.
38 XXX Should determine the number of texture units the target implementation
44 typedef std::map<unsigned, TextureState> TextureMap;
45 typedef std::map<unsigned, BufferState> BufferMap;
54 TexUnitState texunits[8];
56 BufferState *array_buffer;
57 BufferState *element_buffer;
63 int decode(const char *, unsigned);
64 const Vector4 &get_color() const { return color; }
65 const Vector4 &get_texcoord(unsigned i) const { return texcoord[i]; }
66 const Vector3 &get_normal() const { return normal; }
67 const TextureMap &get_textures() const { return textures; }
68 const TextureState &get_texture(unsigned) const;
69 const TexUnitState &get_texture_unit(unsigned i) const { return texunits[i]; }
70 const BufferMap &get_buffers() const { return buffers; }
71 const BufferState &get_buffer(unsigned) const;
72 const BufferState *get_current_buffer(GLenum) const;
74 TextureState *get_current_texture(GLenum);
75 BufferState *get_current_buffer(GLenum);
76 void set_current_texture(GLenum, unsigned);
77 void set_current_buffer(GLenum, unsigned);
79 static void glColor3f(void *, float, float, float);
80 static void glColor4f(void *, float, float, float, float);
81 static void glNormal3f(void *, float, float, float);
82 static void glTexCoord1f(void *, float);
83 static void glTexCoord2f(void *, float, float);
84 static void glTexCoord3f(void *, float, float, float);
85 static void glTexCoord4f(void *, float, float, float, float);
86 static void glMultiTexCoord4f(void *, unsigned, float, float, float, float);
88 static void glActiveTexture(void *, unsigned);
89 static void glBindTexture(void *, GLenum, unsigned);
90 static void glTexImage2D(void *, GLenum, int, int, int, int, int, GLenum, GLenum, const void *);
91 static void glTexParameteri(void *, GLenum, GLenum, int);
92 static void glTexParameteriv(void *, GLenum, GLenum, const int *);
93 static void glDeleteTextures(void *, int, const unsigned *);
95 static void glBindBuffer(void *, GLenum, unsigned);
96 static void glBufferData(void *, GLenum, int, const void *, GLenum);
97 static void glBufferSubData(void *, GLenum, int, int, const void *);