/** @file * * VirtualBox Windows NT/2000/XP guest OpenGL ICD * * Copyright (C) 2006-2007 Sun Microsystems, Inc. * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 USA or visit http://www.sun.com if you need * additional information or have any questions. */ /* * Mesa 3-D graphics library * Version: 6.5.1 * * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "VBoxOGL.h" #include #include void APIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer) { GLboolean tflag, cflag, nflag; /* enable/disable flags */ GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */ GLenum ctype = 0; /* color type */ GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */ const GLint toffset = 0; /* always zero */ GLint defstride; /* default stride */ GLint c, f; f = sizeof(GLfloat); c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f); if (stride < 0) { glLogError(GL_INVALID_VALUE); return; } switch (format) { case GL_V2F: tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 0; ccomps = 0; vcomps = 2; voffset = 0; defstride = 2*f; break; case GL_V3F: tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 0; ccomps = 0; vcomps = 3; voffset = 0; defstride = 3*f; break; case GL_C4UB_V2F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 0; ccomps = 4; vcomps = 2; ctype = GL_UNSIGNED_BYTE; coffset = 0; voffset = c; defstride = c + 2*f; break; case GL_C4UB_V3F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 0; ccomps = 4; vcomps = 3; ctype = GL_UNSIGNED_BYTE; coffset = 0; voffset = c; defstride = c + 3*f; break; case GL_C3F_V3F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 0; ccomps = 3; vcomps = 3; ctype = GL_FLOAT; coffset = 0; voffset = 3*f; defstride = 6*f; break; case GL_N3F_V3F: tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE; tcomps = 0; ccomps = 0; vcomps = 3; noffset = 0; voffset = 3*f; defstride = 6*f; break; case GL_C4F_N3F_V3F: tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE; tcomps = 0; ccomps = 4; vcomps = 3; ctype = GL_FLOAT; coffset = 0; noffset = 4*f; voffset = 7*f; defstride = 10*f; break; case GL_T2F_V3F: tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 2; ccomps = 0; vcomps = 3; voffset = 2*f; defstride = 5*f; break; case GL_T4F_V4F: tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE; tcomps = 4; ccomps = 0; vcomps = 4; voffset = 4*f; defstride = 8*f; break; case GL_T2F_C4UB_V3F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 2; ccomps = 4; vcomps = 3; ctype = GL_UNSIGNED_BYTE; coffset = 2*f; voffset = c+2*f; defstride = c+5*f; break; case GL_T2F_C3F_V3F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE; tcomps = 2; ccomps = 3; vcomps = 3; ctype = GL_FLOAT; coffset = 2*f; voffset = 5*f; defstride = 8*f; break; case GL_T2F_N3F_V3F: tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE; tcomps = 2; ccomps = 0; vcomps = 3; noffset = 2*f; voffset = 5*f; defstride = 8*f; break; case GL_T2F_C4F_N3F_V3F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; tcomps = 2; ccomps = 4; vcomps = 3; ctype = GL_FLOAT; coffset = 2*f; noffset = 6*f; voffset = 9*f; defstride = 12*f; break; case GL_T4F_C4F_N3F_V4F: tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE; tcomps = 4; ccomps = 4; vcomps = 4; ctype = GL_FLOAT; coffset = 4*f; noffset = 8*f; voffset = 11*f; defstride = 15*f; break; default: glLogError(GL_INVALID_ENUM); return; } if (stride==0) { stride = defstride; } glDisableClientState( GL_EDGE_FLAG_ARRAY ); glDisableClientState( GL_INDEX_ARRAY ); /* XXX also disable secondary color and generic arrays? */ /* Texcoords */ if (tflag) { glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glTexCoordPointer( tcomps, GL_FLOAT, stride, (GLubyte *) pointer + toffset ); } else { glDisableClientState( GL_TEXTURE_COORD_ARRAY ); } /* Color */ if (cflag) { glEnableClientState( GL_COLOR_ARRAY ); glColorPointer( ccomps, ctype, stride, (GLubyte *) pointer + coffset ); } else { glDisableClientState( GL_COLOR_ARRAY ); } /* Normals */ if (nflag) { glEnableClientState( GL_NORMAL_ARRAY ); glNormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset ); } else { glDisableClientState( GL_NORMAL_ARRAY ); } /* Vertices */ glEnableClientState( GL_VERTEX_ARRAY ); glVertexPointer( vcomps, GL_FLOAT, stride, (GLubyte *) pointer + voffset ); }