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_opcodes.h"
|
---|
9 |
|
---|
10 | static GLboolean __handleFogData( GLenum pname, const GLfloat *params )
|
---|
11 | {
|
---|
12 | CR_GET_PACKER_CONTEXT(pc);
|
---|
13 | int params_length = 0;
|
---|
14 | int packet_length = sizeof( int ) + sizeof( pname );
|
---|
15 | unsigned char *data_ptr;
|
---|
16 | switch( pname )
|
---|
17 | {
|
---|
18 | case GL_FOG_MODE:
|
---|
19 | case GL_FOG_DENSITY:
|
---|
20 | case GL_FOG_START:
|
---|
21 | case GL_FOG_END:
|
---|
22 | case GL_FOG_INDEX:
|
---|
23 | params_length = sizeof( *params );
|
---|
24 | break;
|
---|
25 | case GL_FOG_COLOR:
|
---|
26 | params_length = 4*sizeof( *params );
|
---|
27 | break;
|
---|
28 | default:
|
---|
29 | params_length = __packFogParamsLength( pname );
|
---|
30 | if (!params_length)
|
---|
31 | {
|
---|
32 | char msg[100];
|
---|
33 | sprintf(msg, "Invalid pname in Fog: %d", (int) pname );
|
---|
34 | __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg);
|
---|
35 | return GL_FALSE;
|
---|
36 | }
|
---|
37 | break;
|
---|
38 | }
|
---|
39 | packet_length += params_length;
|
---|
40 |
|
---|
41 | CR_GET_BUFFERED_POINTER(pc, packet_length );
|
---|
42 | WRITE_DATA( 0, int, packet_length );
|
---|
43 | WRITE_DATA( 4, GLenum, pname );
|
---|
44 | WRITE_DATA( 8, GLfloat, params[0] );
|
---|
45 | if (packet_length > 12)
|
---|
46 | {
|
---|
47 | WRITE_DATA( 12, GLfloat, params[1] );
|
---|
48 | WRITE_DATA( 16, GLfloat, params[2] );
|
---|
49 | WRITE_DATA( 20, GLfloat, params[3] );
|
---|
50 | }
|
---|
51 | return GL_TRUE;
|
---|
52 | }
|
---|
53 |
|
---|
54 | void PACK_APIENTRY crPackFogfv(GLenum pname, const GLfloat *params)
|
---|
55 | {
|
---|
56 | CR_GET_PACKER_CONTEXT(pc);
|
---|
57 | if (__handleFogData( pname, params ))
|
---|
58 | WRITE_OPCODE( pc, CR_FOGFV_OPCODE );
|
---|
59 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
60 | }
|
---|
61 |
|
---|
62 | void PACK_APIENTRY crPackFogiv(GLenum pname, const GLint *params)
|
---|
63 | {
|
---|
64 | CR_GET_PACKER_CONTEXT(pc);
|
---|
65 | /* floats and ints are the same size, so the packing should be the same */
|
---|
66 | if (__handleFogData( pname, (const GLfloat *) params ))
|
---|
67 | WRITE_OPCODE( pc, CR_FOGIV_OPCODE );
|
---|
68 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
69 | }
|
---|