server_projmatrix.c revision f53ba2efceac1847585b2052ee98569305e9802d
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "server_dispatch.h"
#include "server.h"
#include "cr_error.h"
#include "state/cr_statetypes.h"
#include "cr_mem.h"
#include "cr_string.h"
/*
* This file provides implementations of the basic OpenGL matrix functions.
* We often need to twiddle with their operation in order to make tilesorting
* and non-planar projections work.
*/
/*
* Determine which view and projection matrices to use when in stereo mode.
* Return 0 = left eye, 1 = right eye.
*/
int crServerGetCurrentEye(void)
{
/* current eye was specified by tilesort SPU */
return cr_server.currentEye;
}
else {
/* we have a quad-buffered window and we're watching glDrawBuffer */
|| drawBuffer == GL_RIGHT;
return eye;
}
}
{
crStateLoadMatrixf( m );
int eye = crServerGetCurrentEye();
}
else {
}
}
{
crStateLoadMatrixd( m );
int eye = crServerGetCurrentEye();
}
else {
}
}
{
/* load the overriding projection matrix */
int eye = crServerGetCurrentEye();
}
else {
/* the usual case */
crStateMultMatrixf( m );
}
}
{
/* load the overriding projection matrix */
int eye = crServerGetCurrentEye();
}
else {
/* the usual case */
crStateMultMatrixd( m );
}
}
void SERVER_DISPATCH_APIENTRY crServerDispatchLoadIdentity( void )
{
int eye = crServerGetCurrentEye();
}
else {
}
}
/*
* The following code is used to deal with vertex programs.
* Basically, vertex programs might not directly use the usual
* OpenGL projection matrix to project vertices from eye coords to
* clip coords.
*
* If you're using Cg then the vertex programs it generates will have
* some comments that we can scan to figure out which program parameters
* contain the projection matrix.
* In this case, look at the Cg program code for a string like
* "ModelViewProj". Then set the crserver's 'vertprog_projection_param'
* config option to this name.
*
* If you're not using Cg, you may have to tell Chromium which program
* parameters contain the projection matrix.
* In this case, look at the OpenGL application's vertex program code to
* determine which program parameters contain the projection matrix.
* Then set the crserver's 'vertprog_projection_param' config option to
* the number of the parameter which holds the first row of the matrix.
*
* Yup, this is complicated.
*
*/
{
int i, j, k;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
for (k = 0; k < 4; k++) {
}
}
}
for (i = 0; i < 16; i++)
r[i] = tmp[i];
}
static CRServerProgram *
{
if (!prog) {
if (!prog)
return NULL;
}
return prog;
}
crServerDispatchProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
#if 0
if (target == GL_VERTEX_PROGRAM_ARB) {
/* save the parameters as rows in the matrix */
}
/* When we get the 4th row (row==3) of the projection matrix we can
* then pre-multiply it by the base matrix and update the program
* parameters with the new matrix.
*/
int i;
/* pre-mult the projection matrix by the base projection */
/* update the program parameters with the new matrix */
for (i = 0; i < 4; i++) {
cr_server.head_spu->dispatch_table.ProgramLocalParameter4fARB(target, index + i - 3, mat[4*0+i], mat[4*1+i], mat[4*2+i], mat[4*3+i]);
}
return; /* done */
}
}
}
#endif
/* if we get here, pass the call through unchanged */
}
crServerDispatchProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
{
crServerDispatchProgramLocalParameter4fARB(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
}
crServerDispatchProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
#if 0
if (target == GL_VERTEX_PROGRAM_NV) {
/* save the parameters as rows in the matrix */
}
/* When we get the 4th row (row==3) of the projection matrix we can
* then pre-multiply it by the base matrix and update the program
* parameters with the new matrix.
*/
int i;
/* pre-mult the projection matrix by the base projection */
/* update the program parameters with the new matrix */
for (i = 0; i < 4; i++) {
cr_server.head_spu->dispatch_table.ProgramParameter4fNV(target, index + i - 3, mat[4*0+i], mat[4*1+i], mat[4*2+i], mat[4*3+i]);
}
return; /* done */
}
}
}
#endif
/* if we get here, pass the call through unchanged */
}
crServerDispatchProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
{
crServerDispatchProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
}
{
if (target == GL_VERTEX_PROGRAM_ARB &&
/* scan the program string looking for 'vertprog_projection'
* If the program was generated by Cg, the info we want will look
* something like this:
* #var float4x4 ModelViewProj : : c[0], 4 : 1 : 1
*/
if (prog) {
if (varPos) {
if (paramPos) {
char number[10];
int i = 0;
i++;
}
number[i] = 0;
}
}
else {
crWarning("Didn't find %s parameter in vertex program string",
}
}
}
/* pass through */
}
{
if (target == GL_VERTEX_PROGRAM_NV &&
/* scan the program string looking for 'vertprog_projection'
* If the program was generated by Cg, the info we want will look
* something like this:
* #var float4x4 ModelViewProj : : c[0], 4 : 1 : 1
*/
if (prog) {
if (varPos) {
if (paramPos) {
char number[10];
int i = 0;
i++;
}
number[i] = 0;
}
}
else {
crWarning("Didn't find %s parameter in vertex program string",
}
}
}
/* pass through */
}
{
if (target == GL_VERTEX_PROGRAM_ARB) {
(void) prog;
}
/* pass through */
}
{
if (target == GL_VERTEX_PROGRAM_NV) {
(void) prog;
}
/* pass through */
}