Commit fec8129f by Maxime Gregoire Committed by Maxime Grégoire

libGL Frustum implementation

Change-Id: I3ffce981fd8238ca1767e05929da3502cd3b2a39 Reviewed-on: https://swiftshader-review.googlesource.com/2510Tested-by: 's avatarMaxime Grégoire <mgregoire@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 53ff8d89
......@@ -3184,6 +3184,16 @@ void Context::multiply(const GLfloat *m)
currentMatrixStack().multiply(m);
}
void Context::frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
{
if(drawing)
{
return error(GL_INVALID_OPERATION);
}
currentMatrixStack().frustum(left, right, bottom, top, zNear, zFar);
}
void Context::ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
{
if(drawing)
......
......@@ -683,6 +683,7 @@ public:
void scale(GLfloat x, GLfloat y, GLfloat z);
void multiply(const GLdouble *m);
void multiply(const GLfloat *m);
void frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
void ortho(double left, double right, double bottom, double top, double zNear, double zFar); // FIXME: GLdouble
void setLighting(bool enabled);
......
......@@ -113,8 +113,8 @@ namespace sw
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);
float C = -(f + n) / (f - n);
float D = -2 * f * n / (f - n);
Matrix frustum(2 * n / (r - l), 0, A, 0,
0, 2 * n / (t - b), B, 0,
......
......@@ -6239,7 +6239,19 @@ void APIENTRY glFogiv(GLenum pname, const GLint *params)
void APIENTRY glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
{
UNIMPLEMENTED();
TRACE("(*)");
gl::Context *context = gl::getContext();
if(context)
{
if(context->getListIndex() != 0)
{
UNIMPLEMENTED();
}
context->frustum(left, right, bottom, top, zNear, zFar);
}
}
GLuint APIENTRY glGenLists(GLsizei range)
......
......@@ -33,9 +33,6 @@ int listIndex;
// Rotation matrix
GLfloat R[16] = { 1, 0, 0, 0, 0, cos(theta), -sin(theta), 0, 0, sin(theta), cos(theta), 0, 0, 0, 0, 1 };
// Projection matrix (mimic the glFrustum function, which is unimplemented as of now)
GLfloat P[16] = { 2.0f, 0, 0, 0, 0, 2.0f, 0, 0, 0, 0, -2.0f, -1.0f, 0, 0, -3.0f, 0 };
// Scaling matrix
GLfloat S[16] = { SCALE_FACTOR, 0, 0, 0, 0, SCALE_FACTOR, 0, 0, 0, 0, SCALE_FACTOR, 0, 0, 0, 0, 1 };
......@@ -74,7 +71,7 @@ void initializeView(void)
{
// Set viewing projection
glMatrixMode(GL_PROJECTION);
glMultMatrixf(P);
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0);
// Position viewer
glMatrixMode(GL_MODELVIEW);
......
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