summaryrefslogtreecommitdiff
path: root/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
diff options
context:
space:
mode:
authorJacky Romano <jr@graphtech.co.il>2011-04-11 18:21:28 +0300
committerJacky Romano <jr@graphtech.co.il>2011-05-02 18:23:13 +0300
commit254492ffd6b6ce4b5a2ca89294b9b63add0bb504 (patch)
treebbab461e6d5d25e058d73021c5128df4b5e74a80 /tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
parent3c2aa9b9318a36fb4329bab692678d86af87d0f3 (diff)
Add GLESv2 functionality to GLESv1/GLESv2 shared code
Extends GLClientState to support additional state data that is required by GLESv2. this includes: * normalized flag in vertex attribute arrays * getter for vertex attribute arrays state * glParamSize now knows about the result size of GL2 parameters * utility functions required for a GLESv2 encoder Change-Id: I7e57d978bed5b8b929b918aee66c7f71dc5df3b1
Diffstat (limited to 'tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h')
-rw-r--r--tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h52
1 files changed, 50 insertions, 2 deletions
diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
index b68007888..2126241a7 100644
--- a/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
+++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLClientState.h
@@ -24,8 +24,12 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
#include <stdio.h>
#include <stdlib.h>
+#include "ErrorLog.h"
class GLClientState {
public:
@@ -57,6 +61,7 @@ public:
GLenum glConst;
unsigned int elementSize;
bool enableDirty; // true if any enable state has changed since last draw
+ bool normalized;
} VertexAttribState;
typedef struct {
@@ -67,18 +72,20 @@ public:
public:
GLClientState(int nLocations = 32);
~GLClientState();
+ int nLocations() { return m_nLocations; }
const PixelStoreState *pixelStoreState() { return &m_pixelStore; }
int setPixelStore(GLenum param, GLint value);
GLuint currentArrayVbo() { return m_currentArrayVbo; }
GLuint currentIndexVbo() { return m_currentIndexVbo; }
void enable(int location, int state);
- void setState(int location, int size, GLenum type, GLsizei stride, void *data);
+ void setState(int location, int size, GLenum type, GLboolean normalized, GLsizei stride, void *data);
void setBufferObject(int location, GLuint id);
const VertexAttribState *getState(int location);
const VertexAttribState *getStateAndEnableDirty(int location, bool *enableChanged);
int getLocation(GLenum loc);
void setActiveTexture(int texUnit) {m_activeTexture = texUnit; };
int getActiveTexture() const { return m_activeTexture; }
+
int bindBuffer(GLenum target, GLuint id)
{
int err = 0;
@@ -94,6 +101,7 @@ public:
}
return err;
}
+
int getBuffer(GLenum target)
{
int ret=0;
@@ -109,7 +117,7 @@ public:
}
return ret;
}
- size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack);
+ size_t pixelDataSize(GLsizei width, GLsizei height, GLenum format, GLenum type, int pack) const;
private:
PixelStoreState m_pixelStore;
@@ -123,6 +131,46 @@ private:
bool validLocation(int location) { return (location >= 0 && location < m_nLocations); }
public:
void getClientStatePointer(GLenum pname, GLvoid** params);
+
+ template <class T>
+ int getVertexAttribParameter(GLuint index, GLenum param, T *ptr)
+ {
+ bool handled = true;
+ const VertexAttribState *vertexAttrib = getState(index);
+ if (vertexAttrib == NULL) {
+ ERR("getVeterxAttriParameter for non existant index %d\n", index);
+ // set gl error;
+ return handled;
+ }
+
+ switch(param) {
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
+ *ptr = (T)(vertexAttrib->bufferObject);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
+ *ptr = (T)(vertexAttrib->enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE:
+ *ptr = (T)(vertexAttrib->size);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
+ *ptr = (T)(vertexAttrib->stride);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE:
+ *ptr = (T)(vertexAttrib->type);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
+ *ptr = (T)(vertexAttrib->normalized);
+ break;
+ case GL_CURRENT_VERTEX_ATTRIB:
+ handled = false;
+ break;
+ default:
+ ERR("unknown vertex-attrib parameter param %d\n", param);
+ }
+ return handled;
+ }
+
template <class T>
bool getClientStateParameter(GLenum param, T* ptr)
{