Commit 6b537b7a by Nicolas Capens Committed by Nicolas Capens

Implement the fixed-function matrix stacks.

BUG=18110152 Change-Id: I0769c446e20eaf52cc84d957de16bfba4254a5f1 Reviewed-on: https://swiftshader-review.googlesource.com/1244Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent e1a3282f
...@@ -38,7 +38,11 @@ namespace es1 ...@@ -38,7 +38,11 @@ namespace es1
{ {
Device *Context::device = 0; Device *Context::device = 0;
Context::Context(const egl::Config *config, const Context *shareContext) : mConfig(config) Context::Context(const egl::Config *config, const Context *shareContext)
: modelViewStack(MAX_MODELVIEW_STACK_DEPTH),
projectionStack(MAX_PROJECTION_STACK_DEPTH),
textureStack0(MAX_TEXTURE_STACK_DEPTH),
textureStack1(MAX_TEXTURE_STACK_DEPTH)
{ {
device = getDevice(); device = getDevice();
...@@ -161,6 +165,8 @@ Context::Context(const egl::Config *config, const Context *shareContext) : mConf ...@@ -161,6 +165,8 @@ Context::Context(const egl::Config *config, const Context *shareContext) : mConf
mHasBeenCurrent = false; mHasBeenCurrent = false;
markAllStateDirty(); markAllStateDirty();
matrixMode = GL_MODELVIEW;
} }
Context::~Context() Context::~Context()
...@@ -172,7 +178,7 @@ Context::~Context() ...@@ -172,7 +178,7 @@ Context::~Context()
for(int type = 0; type < TEXTURE_TYPE_COUNT; type++) for(int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{ {
for(int sampler = 0; sampler < MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++) for(int sampler = 0; sampler < MAX_TEXTURE_IMAGE_UNITS; sampler++)
{ {
mState.samplerTexture[type][sampler].set(NULL); mState.samplerTexture[type][sampler].set(NULL);
} }
...@@ -943,6 +949,18 @@ bool Context::getFloatv(GLenum pname, GLfloat *params) ...@@ -943,6 +949,18 @@ bool Context::getFloatv(GLenum pname, GLfloat *params)
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
*params = MAX_TEXTURE_MAX_ANISOTROPY; *params = MAX_TEXTURE_MAX_ANISOTROPY;
break; break;
case GL_MODELVIEW_MATRIX:
for(int i = 0; i < 16; i++)
{
params[i] = modelViewStack.current()[i % 4][i / 4];
}
break;
case GL_PROJECTION_MATRIX:
for(int i = 0; i < 16; i++)
{
params[i] = projectionStack.current()[i % 4][i / 4];
}
break;
default: default:
return false; return false;
} }
...@@ -1117,7 +1135,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1117,7 +1135,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break; break;
case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_2D:
{ {
if(mState.activeSampler < 0 || mState.activeSampler > MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1) if(mState.activeSampler < 0 || mState.activeSampler > MAX_TEXTURE_IMAGE_UNITS - 1)
{ {
error(GL_INVALID_OPERATION); error(GL_INVALID_OPERATION);
return false; return false;
...@@ -1128,7 +1146,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1128,7 +1146,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break; break;
case GL_TEXTURE_BINDING_CUBE_MAP_OES: case GL_TEXTURE_BINDING_CUBE_MAP_OES:
{ {
if(mState.activeSampler < 0 || mState.activeSampler > MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1) if(mState.activeSampler < 0 || mState.activeSampler > MAX_TEXTURE_IMAGE_UNITS - 1)
{ {
error(GL_INVALID_OPERATION); error(GL_INVALID_OPERATION);
return false; return false;
...@@ -1139,7 +1157,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1139,7 +1157,7 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
break; break;
case GL_TEXTURE_BINDING_EXTERNAL_OES: case GL_TEXTURE_BINDING_EXTERNAL_OES:
{ {
if(mState.activeSampler < 0 || mState.activeSampler > MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1) if(mState.activeSampler < 0 || mState.activeSampler > MAX_TEXTURE_IMAGE_UNITS - 1)
{ {
error(GL_INVALID_OPERATION); error(GL_INVALID_OPERATION);
return false; return false;
...@@ -1149,6 +1167,9 @@ bool Context::getIntegerv(GLenum pname, GLint *params) ...@@ -1149,6 +1167,9 @@ bool Context::getIntegerv(GLenum pname, GLint *params)
} }
break; break;
case GL_MAX_LIGHTS: *params = MAX_LIGHTS; break; case GL_MAX_LIGHTS: *params = MAX_LIGHTS; break;
case GL_MAX_MODELVIEW_STACK_DEPTH: *params = MAX_MODELVIEW_STACK_DEPTH; break;
case GL_MAX_PROJECTION_STACK_DEPTH: *params = MAX_PROJECTION_STACK_DEPTH; break;
case GL_MAX_TEXTURE_STACK_DEPTH: *params = MAX_TEXTURE_STACK_DEPTH; break;
default: default:
return false; return false;
} }
...@@ -1211,6 +1232,7 @@ int Context::getQueryParameterNum(GLenum pname) ...@@ -1211,6 +1232,7 @@ int Context::getQueryParameterNum(GLenum pname)
case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_2D:
case GL_TEXTURE_BINDING_CUBE_MAP_OES: case GL_TEXTURE_BINDING_CUBE_MAP_OES:
case GL_TEXTURE_BINDING_EXTERNAL_OES: case GL_TEXTURE_BINDING_EXTERNAL_OES:
case GL_MAX_TEXTURE_UNITS:
return 1; return 1;
case GL_MAX_VIEWPORT_DIMS: case GL_MAX_VIEWPORT_DIMS:
return 2; return 2;
...@@ -1245,6 +1267,9 @@ int Context::getQueryParameterNum(GLenum pname) ...@@ -1245,6 +1267,9 @@ int Context::getQueryParameterNum(GLenum pname)
return 4; return 4;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
case GL_MAX_LIGHTS: case GL_MAX_LIGHTS:
case GL_MAX_MODELVIEW_STACK_DEPTH:
case GL_MAX_PROJECTION_STACK_DEPTH:
case GL_MAX_TEXTURE_STACK_DEPTH:
return 1; return 1;
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -1311,6 +1336,9 @@ bool Context::isQueryParameterInt(GLenum pname) ...@@ -1311,6 +1336,9 @@ bool Context::isQueryParameterInt(GLenum pname)
case GL_VIEWPORT: case GL_VIEWPORT:
case GL_SCISSOR_BOX: case GL_SCISSOR_BOX:
case GL_MAX_LIGHTS: case GL_MAX_LIGHTS:
case GL_MAX_MODELVIEW_STACK_DEPTH:
case GL_MAX_PROJECTION_STACK_DEPTH:
case GL_MAX_TEXTURE_STACK_DEPTH:
return true; return true;
default: default:
ASSERT(isQueryParameterFloat(pname) || isQueryParameterBool(pname)); ASSERT(isQueryParameterFloat(pname) || isQueryParameterBool(pname));
...@@ -1626,6 +1654,13 @@ void Context::applyState(GLenum drawMode) ...@@ -1626,6 +1654,13 @@ void Context::applyState(GLenum drawMode)
device->setSpecularMaterialSource(sw::MATERIAL_MATERIAL); device->setSpecularMaterialSource(sw::MATERIAL_MATERIAL);
device->setAmbientMaterialSource(sw::MATERIAL_MATERIAL); device->setAmbientMaterialSource(sw::MATERIAL_MATERIAL);
device->setEmissiveMaterialSource(sw::MATERIAL_MATERIAL); device->setEmissiveMaterialSource(sw::MATERIAL_MATERIAL);
device->setProjectionMatrix(projectionStack.current());
device->setModelMatrix(modelViewStack.current());
device->setTextureMatrix(0, textureStack0.current());
device->setTextureMatrix(1, textureStack1.current());
device->setTextureTransform(0, textureStack0.isIdentity() ? 0 : 4, false);
device->setTextureTransform(1, textureStack1.isIdentity() ? 0 : 4, false);
} }
GLenum Context::applyVertexBuffer(GLint base, GLint first, GLsizei count) GLenum Context::applyVertexBuffer(GLint base, GLint first, GLsizei count)
...@@ -2224,7 +2259,7 @@ void Context::detachTexture(GLuint texture) ...@@ -2224,7 +2259,7 @@ void Context::detachTexture(GLuint texture)
for(int type = 0; type < TEXTURE_TYPE_COUNT; type++) for(int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{ {
for(int sampler = 0; sampler < MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++) for(int sampler = 0; sampler < MAX_TEXTURE_IMAGE_UNITS; sampler++)
{ {
if(mState.samplerTexture[type][sampler].id() == texture) if(mState.samplerTexture[type][sampler].id() == texture)
{ {
...@@ -2418,6 +2453,83 @@ Device *Context::getDevice() ...@@ -2418,6 +2453,83 @@ Device *Context::getDevice()
return device; return device;
} }
void Context::setMatrixMode(GLenum mode)
{
matrixMode = mode;
}
sw::MatrixStack &Context::currentMatrixStack()
{
switch(matrixMode)
{
case GL_MODELVIEW:
return modelViewStack;
case GL_PROJECTION:
return projectionStack;
case GL_TEXTURE:
switch(mState.activeSampler)
{
case 0: return textureStack0;
case 1: return textureStack1;
}
break;
}
UNREACHABLE();
return textureStack0;
}
void Context::loadIdentity()
{
currentMatrixStack().identity();
}
void Context::load(const GLfloat *m)
{
currentMatrixStack().load(m);
}
void Context::pushMatrix()
{
if(!currentMatrixStack().push())
{
return error(GL_STACK_OVERFLOW);
}
}
void Context::popMatrix()
{
if(!currentMatrixStack().pop())
{
return error(GL_STACK_OVERFLOW);
}
}
void Context::rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{
currentMatrixStack().rotate(angle, x, y, z);
}
void Context::translate(GLfloat x, GLfloat y, GLfloat z)
{
currentMatrixStack().translate(x, y, z);
}
void Context::scale(GLfloat x, GLfloat y, GLfloat z)
{
currentMatrixStack().scale(x, y, z);
}
void Context::multiply(const GLfloat *m)
{
currentMatrixStack().multiply(m);
}
void Context::ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
{
currentMatrixStack().ortho(left, right, bottom, top, zNear, zFar);
}
} }
// Exported functions for use by EGL // Exported functions for use by EGL
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "RefCountObject.h" #include "RefCountObject.h"
#include "Image.hpp" #include "Image.hpp"
#include "Renderer/Sampler.hpp" #include "Renderer/Sampler.hpp"
#include "MatrixStack.hpp"
#define GL_API #define GL_API
#include <GLES/gl.h> #include <GLES/gl.h>
...@@ -61,16 +62,15 @@ class IndexDataManager; ...@@ -61,16 +62,15 @@ class IndexDataManager;
enum enum
{ {
MAX_VERTEX_ATTRIBS = 16, MAX_VERTEX_ATTRIBS = 16,
MAX_UNIFORM_VECTORS = 256, // Device limit
MAX_VERTEX_UNIFORM_VECTORS = 256 - 3, // Reserve space for gl_DepthRange
MAX_VARYING_VECTORS = 10, MAX_VARYING_VECTORS = 10,
MAX_TEXTURE_IMAGE_UNITS = 16, MAX_TEXTURE_IMAGE_UNITS = 16,
MAX_VERTEX_TEXTURE_IMAGE_UNITS = 4,
MAX_COMBINED_TEXTURE_IMAGE_UNITS = MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS,
MAX_FRAGMENT_UNIFORM_VECTORS = 224 - 3, // Reserve space for gl_DepthRange
MAX_DRAW_BUFFERS = 1, MAX_DRAW_BUFFERS = 1,
MAX_LIGHTS = 8, MAX_LIGHTS = 8,
MAX_MODELVIEW_STACK_DEPTH = 32,
MAX_PROJECTION_STACK_DEPTH = 2,
MAX_TEXTURE_STACK_DEPTH = 2,
IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB, IMPLEMENTATION_COLOR_READ_FORMAT = GL_RGB,
IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5 IMPLEMENTATION_COLOR_READ_TYPE = GL_UNSIGNED_SHORT_5_6_5
}; };
...@@ -247,7 +247,7 @@ struct State ...@@ -247,7 +247,7 @@ struct State
BindingPointer<Renderbuffer> renderbuffer; BindingPointer<Renderbuffer> renderbuffer;
VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS]; VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS]; BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_TEXTURE_IMAGE_UNITS];
GLint unpackAlignment; GLint unpackAlignment;
GLint packAlignment; GLint packAlignment;
...@@ -418,6 +418,17 @@ public: ...@@ -418,6 +418,17 @@ public:
Device *getDevice(); Device *getDevice();
void setMatrixMode(GLenum mode);
void loadIdentity();
void load(const GLfloat *m);
void pushMatrix();
void popMatrix();
void rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
void translate(GLfloat x, GLfloat y, GLfloat z);
void scale(GLfloat x, GLfloat y, GLfloat z);
void multiply(const GLfloat *m);
void ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
private: private:
virtual ~Context(); virtual ~Context();
...@@ -436,8 +447,6 @@ private: ...@@ -436,8 +447,6 @@ private:
bool cullSkipsDraw(GLenum drawMode); bool cullSkipsDraw(GLenum drawMode);
bool isTriangleMode(GLenum drawMode); bool isTriangleMode(GLenum drawMode);
const egl::Config *const mConfig;
State mState; State mState;
BindingPointer<Texture2D> mTexture2DZero; BindingPointer<Texture2D> mTexture2DZero;
...@@ -478,6 +487,13 @@ private: ...@@ -478,6 +487,13 @@ private:
bool mFrontFaceDirty; bool mFrontFaceDirty;
bool mDitherStateDirty; bool mDitherStateDirty;
sw::MatrixStack &currentMatrixStack();
GLenum matrixMode;
sw::MatrixStack modelViewStack;
sw::MatrixStack projectionStack;
sw::MatrixStack textureStack0;
sw::MatrixStack textureStack1;
ResourceManager *mResourceManager; ResourceManager *mResourceManager;
static Device *device; static Device *device;
......
#include "MatrixStack.hpp"
#include "Common/Math.hpp"
namespace sw
{
MatrixStack::MatrixStack(int size)
{
stack = new Matrix[size];
stack[0] = 1;
top = 0;
this->size = size;
}
MatrixStack::~MatrixStack()
{
delete[] stack;
stack = 0;
}
void MatrixStack::identity()
{
stack[top] = 1;
}
void MatrixStack::load(const float *M)
{
stack[top] = Matrix(M[0], M[4], M[8], M[12],
M[1], M[5], M[9], M[13],
M[2], M[6], M[10], M[14],
M[3], M[7], M[11], M[15]);
}
void MatrixStack::load(const double *M)
{
stack[top] = Matrix((float)M[0], (float)M[4], (float)M[8], (float)M[12],
(float)M[1], (float)M[5], (float)M[9], (float)M[13],
(float)M[2], (float)M[6], (float)M[10], (float)M[14],
(float)M[3], (float)M[7], (float)M[11], (float)M[15]);
}
void MatrixStack::translate(float x, float y, float z)
{
stack[top] *= Matrix::translate(x, y, z);
}
void MatrixStack::translate(double x, double y, double z)
{
translate((float)x, (float)y, (float)z);
}
void MatrixStack::rotate(float angle, float x, float y, float z)
{
float n = 1.0f / sqrt(x*x + y*y + z*z);
x *= n;
y *= n;
z *= n;
float theta = angle * 0.0174532925f; // In radians
float c = cos(theta);
float _c = 1 - c;
float s = sin(theta);
// Rodrigues' rotation formula
sw::Matrix rotate(c+x*x*_c, x*y*_c-z*s, x*z*_c+y*s,
x*y*_c+z*s, c+y*y*_c, y*z*_c-x*s,
x*z*_c-y*s, y*z*_c+x*s, c+z*z*_c);
stack[top] *= rotate;
}
void MatrixStack::rotate(double angle, double x, double y, double z)
{
rotate((float)angle, (float)x, (float)y, (float)z);
}
void MatrixStack::scale(float x, float y, float z)
{
stack[top] *= Matrix::scale(x, y, z);
}
void MatrixStack::scale(double x, double y, double z)
{
scale((float)x, (float)y, (float)z);
}
void MatrixStack::multiply(const float *M)
{
stack[top] *= Matrix(M[0], M[4], M[8], M[12],
M[1], M[5], M[9], M[13],
M[2], M[6], M[10], M[14],
M[3], M[7], M[11], M[15]);
}
void MatrixStack::multiply(const double *M)
{
stack[top] *= Matrix((float)M[0], (float)M[4], (float)M[8], (float)M[12],
(float)M[1], (float)M[5], (float)M[9], (float)M[13],
(float)M[2], (float)M[6], (float)M[10], (float)M[14],
(float)M[3], (float)M[7], (float)M[11], (float)M[15]);
}
void MatrixStack::frustum(float left, float right, float bottom, float top, float zNear, float zFar)
{
float l = (float)left;
float r = (float)right;
float b = (float)bottom;
float t = (float)top;
float n = (float)zNear;
float f = (float)zFar;
float A = (r + l) / (r - l);
float B = (t + b) / (t - b);
float C = -(f + n) / (r - n);
float D = -2 * r * n / (f - n);
Matrix frustum(2 * n / (r - l), 0, A, 0,
0, 2 * n / (t - b), B, 0,
0, 0, C, D,
0, 0, -1, 0);
stack[this->top] *= frustum;
}
void MatrixStack::ortho(double left, double right, double bottom, double top, double zNear, double zFar)
{
float l = (float)left;
float r = (float)right;
float b = (float)bottom;
float t = (float)top;
float n = (float)zNear;
float f = (float)zFar;
float tx = -(r + l) / (r - l);
float ty = -(t + b) / (t - b);
float tz = -(f + n) / (f - n);
Matrix ortho(2 / (r - l), 0, 0, tx,
0, 2 / (t - b), 0, ty,
0, 0, -2 / (f - n), tz,
0, 0, 0, 1);
stack[this->top] *= ortho;
}
bool MatrixStack::push()
{
if(top >= size - 1) return false;
stack[top + 1] = stack[top];
top++;
return true;
}
bool MatrixStack::pop()
{
if(top <= 0) return false;
top--;
return true;
}
const Matrix &MatrixStack::current()
{
return stack[top];
}
bool MatrixStack::isIdentity() const
{
const Matrix &m = stack[top];
if(m.m[0][0] != 1.0f) return false;
if(m.m[0][1] != 0.0f) return false;
if(m.m[0][2] != 0.0f) return false;
if(m.m[0][3] != 0.0f) return false;
if(m.m[1][0] != 0.0f) return false;
if(m.m[1][1] != 1.0f) return false;
if(m.m[1][2] != 0.0f) return false;
if(m.m[1][3] != 0.0f) return false;
if(m.m[2][0] != 0.0f) return false;
if(m.m[2][1] != 0.0f) return false;
if(m.m[2][2] != 1.0f) return false;
if(m.m[2][3] != 0.0f) return false;
if(m.m[3][0] != 0.0f) return false;
if(m.m[3][1] != 0.0f) return false;
if(m.m[3][2] != 0.0f) return false;
if(m.m[3][3] != 1.0f) return false;
return true;
}
}
#ifndef OpenGL32_MatrixStack_hpp
#define OpenGL32_MatrixStack_hpp
#include "Renderer/Matrix.hpp"
namespace sw
{
class MatrixStack
{
public:
MatrixStack(int size = 2);
~MatrixStack();
void identity();
void load(const float *M);
void load(const double *M);
void translate(float x, float y, float z);
void translate(double x, double y, double z);
void rotate(float angle, float x, float y, float z);
void rotate(double angle, double x, double y, double z);
void scale(float x, float y, float z);
void scale(double x, double y, double z);
void multiply(const float *M);
void multiply(const double *M);
void frustum(float left, float right, float bottom, float top, float zNear, float zFar);
void ortho(double left, double right, double bottom, double top, double zNear, double zFar);
bool push(); // False on overflow
bool pop(); // False on underflow
const Matrix &current();
bool isIdentity() const;
private:
int top;
int size;
Matrix *stack;
};
}
#endif // OpenGL32_MatrixStack_hpp
...@@ -351,7 +351,7 @@ void GL_APIENTRY glActiveTexture(GLenum texture) ...@@ -351,7 +351,7 @@ void GL_APIENTRY glActiveTexture(GLenum texture)
if(context) if(context)
{ {
if(texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + es1::MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1) if(texture < GL_TEXTURE0 || texture > GL_TEXTURE0 + es1::MAX_TEXTURE_IMAGE_UNITS - 1)
{ {
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
...@@ -3009,12 +3009,40 @@ void GL_APIENTRY glLineWidthx(GLfixed width) ...@@ -3009,12 +3009,40 @@ void GL_APIENTRY glLineWidthx(GLfixed width)
void GL_APIENTRY glLoadIdentity(void) void GL_APIENTRY glLoadIdentity(void)
{ {
UNIMPLEMENTED(); TRACE("()");
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->loadIdentity();
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glLoadMatrixf(const GLfloat *m) void GL_APIENTRY glLoadMatrixf(const GLfloat *m)
{ {
UNIMPLEMENTED(); TRACE("(const GLfloat *m)");
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->load(m);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glLoadMatrixx(const GLfixed *m) void GL_APIENTRY glLoadMatrixx(const GLfixed *m)
...@@ -3049,12 +3077,40 @@ void GL_APIENTRY glMaterialxv(GLenum face, GLenum pname, const GLfixed *params) ...@@ -3049,12 +3077,40 @@ void GL_APIENTRY glMaterialxv(GLenum face, GLenum pname, const GLfixed *params)
void GL_APIENTRY glMatrixMode(GLenum mode) void GL_APIENTRY glMatrixMode(GLenum mode)
{ {
UNIMPLEMENTED(); TRACE("(GLenum mode = 0x%X)", mode);
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->setMatrixMode(mode);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glMultMatrixf(const GLfloat *m) void GL_APIENTRY glMultMatrixf(const GLfloat *m)
{ {
UNIMPLEMENTED(); TRACE("(const GLfloat *m)");
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->multiply(m);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glMultMatrixx(const GLfixed *m) void GL_APIENTRY glMultMatrixx(const GLfixed *m)
...@@ -3089,7 +3145,21 @@ void GL_APIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *poin ...@@ -3089,7 +3145,21 @@ void GL_APIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *poin
void GL_APIENTRY glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) void GL_APIENTRY glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
{ {
UNIMPLEMENTED(); TRACE("(GLfloat left = %f, GLfloat right = %f, GLfloat bottom = %f, GLfloat top = %f, GLfloat zNear = %f, GLfloat zFar = %f)", left, right, bottom, top, zNear, zFar);
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->ortho(left, right, bottom, top, zNear, zFar);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) void GL_APIENTRY glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
...@@ -3199,12 +3269,40 @@ void GL_APIENTRY glPolygonOffsetx(GLfixed factor, GLfixed units) ...@@ -3199,12 +3269,40 @@ void GL_APIENTRY glPolygonOffsetx(GLfixed factor, GLfixed units)
void GL_APIENTRY glPopMatrix(void) void GL_APIENTRY glPopMatrix(void)
{ {
UNIMPLEMENTED(); TRACE("()");
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->popMatrix();
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glPushMatrix(void) void GL_APIENTRY glPushMatrix(void)
{ {
UNIMPLEMENTED(); TRACE("()");
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->pushMatrix();
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
...@@ -3310,7 +3408,21 @@ void GL_APIENTRY glRenderbufferStorageOES(GLenum target, GLenum internalformat, ...@@ -3310,7 +3408,21 @@ void GL_APIENTRY glRenderbufferStorageOES(GLenum target, GLenum internalformat,
void GL_APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) void GL_APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{ {
UNIMPLEMENTED(); TRACE("(GLfloat angle = %f, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", angle, x, y, z);
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->rotate(angle, x, y, z);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) void GL_APIENTRY glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
...@@ -3344,7 +3456,21 @@ void GL_APIENTRY glSampleCoveragex(GLclampx value, GLboolean invert) ...@@ -3344,7 +3456,21 @@ void GL_APIENTRY glSampleCoveragex(GLclampx value, GLboolean invert)
void GL_APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z) void GL_APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
{ {
UNIMPLEMENTED(); TRACE("(GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", x, y, z);
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->scale(x, y, z);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glScalex(GLfixed x, GLfixed y, GLfixed z) void GL_APIENTRY glScalex(GLfixed x, GLfixed y, GLfixed z)
...@@ -3887,7 +4013,21 @@ void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin ...@@ -3887,7 +4013,21 @@ void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLin
void GL_APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z) void GL_APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
{ {
UNIMPLEMENTED(); TRACE("(GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", x, y, z);
try
{
es1::Context *context = es1::getContext();
if(context)
{
context->translate(x, y, z);
}
}
catch(std::bad_alloc&)
{
return error(GL_OUT_OF_MEMORY);
}
} }
void GL_APIENTRY glTranslatex(GLfixed x, GLfixed y, GLfixed z) void GL_APIENTRY glTranslatex(GLfixed x, GLfixed y, GLfixed z)
......
...@@ -170,6 +170,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co ...@@ -170,6 +170,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
<ClCompile Include="IndexDataManager.cpp" /> <ClCompile Include="IndexDataManager.cpp" />
<ClCompile Include="libGLES_CM.cpp" /> <ClCompile Include="libGLES_CM.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="MatrixStack.cpp" />
<ClCompile Include="RefCountObject.cpp" /> <ClCompile Include="RefCountObject.cpp" />
<ClCompile Include="Renderbuffer.cpp" /> <ClCompile Include="Renderbuffer.cpp" />
<ClCompile Include="ResourceManager.cpp" /> <ClCompile Include="ResourceManager.cpp" />
...@@ -192,6 +193,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co ...@@ -192,6 +193,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
<ClInclude Include="IndexDataManager.h" /> <ClInclude Include="IndexDataManager.h" />
<ClInclude Include="main.h" /> <ClInclude Include="main.h" />
<ClInclude Include="mathutil.h" /> <ClInclude Include="mathutil.h" />
<ClInclude Include="MatrixStack.hpp" />
<ClInclude Include="RefCountObject.h" /> <ClInclude Include="RefCountObject.h" />
<ClInclude Include="Renderbuffer.h" /> <ClInclude Include="Renderbuffer.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
......
...@@ -59,6 +59,9 @@ ...@@ -59,6 +59,9 @@
<ClCompile Include="libGLES_CM.cpp"> <ClCompile Include="libGLES_CM.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="MatrixStack.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Buffer.h"> <ClInclude Include="Buffer.h">
...@@ -124,6 +127,9 @@ ...@@ -124,6 +127,9 @@
<ClInclude Include="..\include\GLES\glplatform.h"> <ClInclude Include="..\include\GLES\glplatform.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="MatrixStack.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="libGLES_CM.rc" /> <ResourceCompile Include="libGLES_CM.rc" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment