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 | #include "cr_version.h"
|
---|
10 |
|
---|
11 | #ifdef CR_ARB_point_parameters
|
---|
12 |
|
---|
13 | static GLboolean __handlePointDataf( GLenum pname, const GLfloat *params )
|
---|
14 | {
|
---|
15 | GET_PACKER_CONTEXT(pc);
|
---|
16 | int params_length = 0;
|
---|
17 | int packet_length = 2 * sizeof( int ) + sizeof( pname );
|
---|
18 | unsigned char *data_ptr;
|
---|
19 | switch( pname )
|
---|
20 | {
|
---|
21 | case GL_POINT_SIZE_MIN_ARB:
|
---|
22 | case GL_POINT_SIZE_MAX_ARB:
|
---|
23 | case GL_POINT_FADE_THRESHOLD_SIZE_ARB:
|
---|
24 | params_length = sizeof( *params );
|
---|
25 | break;
|
---|
26 | case GL_POINT_DISTANCE_ATTENUATION_ARB:
|
---|
27 | params_length = 3 * sizeof( *params );
|
---|
28 | break;
|
---|
29 | default:
|
---|
30 | {
|
---|
31 | char msg[100];
|
---|
32 | sprintf(msg, "Invalid pname in PointParameter: %d", (int) pname );
|
---|
33 | __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg);
|
---|
34 | }
|
---|
35 | return GL_FALSE;
|
---|
36 | }
|
---|
37 | packet_length += params_length;
|
---|
38 |
|
---|
39 | GET_BUFFERED_POINTER(pc, packet_length );
|
---|
40 | WRITE_DATA( 0, GLint, packet_length );
|
---|
41 | WRITE_DATA( 4, GLenum, CR_POINTPARAMETERFVARB_EXTEND_OPCODE );
|
---|
42 | WRITE_DATA( 8, GLenum, pname );
|
---|
43 | WRITE_DATA( 12, GLfloat, params[0] );
|
---|
44 | if (packet_length > 16)
|
---|
45 | {
|
---|
46 | WRITE_DATA( 16, GLfloat, params[1] );
|
---|
47 | WRITE_DATA( 20, GLfloat, params[2] );
|
---|
48 | }
|
---|
49 | return GL_TRUE;
|
---|
50 | }
|
---|
51 |
|
---|
52 | void PACK_APIENTRY crPackPointParameterfvARB(GLenum pname, const GLfloat *params)
|
---|
53 | {
|
---|
54 | GET_PACKER_CONTEXT(pc);
|
---|
55 | if (__handlePointDataf( pname, params ))
|
---|
56 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
57 | }
|
---|
58 |
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | static GLboolean __handlePointDatai( GLenum pname, const GLint *params )
|
---|
62 | {
|
---|
63 | GET_PACKER_CONTEXT(pc);
|
---|
64 | int params_length = 0;
|
---|
65 | int packet_length = 2 * sizeof( int ) + sizeof( pname );
|
---|
66 | unsigned char *data_ptr;
|
---|
67 | switch( pname )
|
---|
68 | {
|
---|
69 | case GL_POINT_SIZE_MIN_ARB:
|
---|
70 | case GL_POINT_SIZE_MAX_ARB:
|
---|
71 | case GL_POINT_FADE_THRESHOLD_SIZE_ARB:
|
---|
72 | params_length = sizeof( *params );
|
---|
73 | break;
|
---|
74 | case GL_POINT_DISTANCE_ATTENUATION_ARB:
|
---|
75 | params_length = 3 * sizeof( *params );
|
---|
76 | break;
|
---|
77 | default:
|
---|
78 | {
|
---|
79 | char msg[100];
|
---|
80 | sprintf(msg, "Invalid pname in PointParameter: %d", (int) pname );
|
---|
81 | __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg);
|
---|
82 | }
|
---|
83 | return GL_FALSE;
|
---|
84 | }
|
---|
85 | packet_length += params_length;
|
---|
86 |
|
---|
87 | GET_BUFFERED_POINTER(pc, packet_length );
|
---|
88 | WRITE_DATA( 0, GLint, packet_length );
|
---|
89 | WRITE_DATA( 4, GLenum, CR_POINTPARAMETERIV_EXTEND_OPCODE );
|
---|
90 | WRITE_DATA( 8, GLenum, pname );
|
---|
91 | WRITE_DATA( 12, GLint, params[0] );
|
---|
92 | if (packet_length > 16)
|
---|
93 | {
|
---|
94 | WRITE_DATA( 16, GLint, params[1] );
|
---|
95 | WRITE_DATA( 20, GLint, params[2] );
|
---|
96 | }
|
---|
97 | return GL_TRUE;
|
---|
98 | }
|
---|
99 |
|
---|
100 | void PACK_APIENTRY crPackPointParameteriv(GLenum pname, const GLint *params)
|
---|
101 | {
|
---|
102 | GET_PACKER_CONTEXT(pc);
|
---|
103 | if (__handlePointDatai( pname, params ))
|
---|
104 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
105 | }
|
---|