VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_materials.c@ 69392

Last change on this file since 69392 was 69392, checked in by vboxsync, 7 years ago

GuestHost/OpenGL: scm updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 2.1 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include "packer.h"
8#include "cr_error.h"
9
10static void __handleMaterialData( GLenum face, GLenum pname, const GLfloat *params )
11{
12 CR_GET_PACKER_CONTEXT(pc);
13 unsigned int packet_length = sizeof( int ) + sizeof( face ) + sizeof( pname );
14 unsigned int params_length = 0;
15 unsigned char *data_ptr;
16 switch( pname )
17 {
18 case GL_AMBIENT:
19 case GL_DIFFUSE:
20 case GL_SPECULAR:
21 case GL_EMISSION:
22 case GL_AMBIENT_AND_DIFFUSE:
23 params_length = 4*sizeof( *params );
24 break;
25 case GL_COLOR_INDEXES:
26 params_length = 3*sizeof( *params );
27 break;
28 case GL_SHININESS:
29 params_length = sizeof( *params );
30 break;
31 default:
32 __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterial(pname)");
33 return;
34 }
35 packet_length += params_length;
36
37 CR_GET_BUFFERED_POINTER(pc, packet_length );
38 WRITE_DATA( 0, int, packet_length );
39 WRITE_DATA( sizeof( int ) + 0, GLenum, face );
40 WRITE_DATA( sizeof( int ) + 4, GLenum, pname );
41 WRITE_DATA( sizeof( int ) + 8, GLfloat, params[0] );
42 if (params_length > sizeof( *params ))
43 {
44 WRITE_DATA( sizeof( int ) + 12, GLfloat, params[1] );
45 WRITE_DATA( sizeof( int ) + 16, GLfloat, params[2] );
46 }
47 if (packet_length > 3*sizeof( *params ) )
48 {
49 WRITE_DATA( sizeof( int ) + 20, GLfloat, params[3] );
50 }
51}
52
53void PACK_APIENTRY crPackMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
54{
55 CR_GET_PACKER_CONTEXT(pc);
56 __handleMaterialData( face, pname, params );
57 WRITE_OPCODE( pc, CR_MATERIALFV_OPCODE );
58 CR_UNLOCK_PACKER_CONTEXT(pc);
59}
60
61void PACK_APIENTRY crPackMaterialiv(GLenum face, GLenum pname, const GLint *params)
62{
63 /* floats and ints are the same size, so the packing should be the same */
64 CR_GET_PACKER_CONTEXT(pc);
65 __handleMaterialData( face, pname, (const GLfloat *) params );
66 WRITE_OPCODE( pc, CR_MATERIALIV_OPCODE );
67 CR_UNLOCK_PACKER_CONTEXT(pc);
68}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette