• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 #include "GLESv2Dispatch.h"
4 
5 #include <map>
6 #include <string>
7 #include <vector>
8 
9 #include <inttypes.h>
10 
11 #include <GLES2/gl2.h>
12 
13 namespace GLSnapshot {
14 
15 struct GLValue {
16     std::vector<GLenum> enums;
17     std::vector<unsigned char> bytes;
18     std::vector<uint16_t> shorts;
19     std::vector<uint32_t> ints;
20     std::vector<float> floats;
21     std::vector<uint64_t> int64s;
22 };
23 
24 typedef std::map<GLenum, GLValue> GlobalStateMap;
25 typedef std::map<GLenum, bool> GlobalEnables;
26 
27 struct GLShaderState {
28     GLenum type;
29     std::string source;
30     bool compileStatus;
31 };
32 
33 struct GLProgramState {
34     std::map<GLenum, GLuint> linkage;
35     bool linkStatus;
36 };
37 
38 class GLSnapshotState {
39 public:
40     GLSnapshotState(const GLESv2Dispatch* gl);
41     void save();
42     void restore();
43 
44     // Shaders
45     GLuint createShader(GLuint shader, GLenum shaderType);
46     GLuint createProgram(GLuint program);
47     void shaderString(GLuint shader, const GLchar* string);
48     void genBuffers(GLsizei n, GLuint* buffers);
49     GLuint getProgramName(GLuint name);
50 
51 private:
52     void getGlobalStateEnum(GLenum name, int size);
53     void getGlobalStateByte(GLenum name, int size);
54     void getGlobalStateInt(GLenum name, int size);
55     void getGlobalStateFloat(GLenum name, int size);
56     void getGlobalStateInt64(GLenum name, int size);
57 
58     void getGlobalStateEnable(GLenum name);
59 
60     const GLESv2Dispatch* mGL;
61     GlobalStateMap mGlobals;
62     GlobalEnables mEnables;
63 
64     GLuint mProgramCounter = 1;
65 
66     std::map<GLuint, GLuint> mProgramNames;
67     std::map<GLuint, GLuint> mProgramNamesBack;
68     std::map<GLuint, GLShaderState> mShaderState;
69     std::map<GLuint, GLProgramState> mShaderProgramState;
70 
71 };
72 
73 } // namespace GLSnapshot
74