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 |
|
---|
10 | void PACK_APIENTRY crPackChromiumParametervCR(GLenum target, GLenum type, GLsizei count, const GLvoid *values)
|
---|
11 | {
|
---|
12 | CR_GET_PACKER_CONTEXT(pc);
|
---|
13 | unsigned int header_length = 2 * sizeof(int) + sizeof(target) + sizeof(type) + sizeof(count);
|
---|
14 | unsigned int packet_length;
|
---|
15 | unsigned int params_length = 0;
|
---|
16 | unsigned char *data_ptr;
|
---|
17 | int i, pos;
|
---|
18 |
|
---|
19 | switch (type) {
|
---|
20 | case GL_BYTE:
|
---|
21 | case GL_UNSIGNED_BYTE:
|
---|
22 | params_length = sizeof(GLbyte) * count;
|
---|
23 | break;
|
---|
24 | case GL_SHORT:
|
---|
25 | case GL_UNSIGNED_SHORT:
|
---|
26 | params_length = sizeof(GLshort) * count;
|
---|
27 | break;
|
---|
28 | case GL_INT:
|
---|
29 | case GL_UNSIGNED_INT:
|
---|
30 | params_length = sizeof(GLint) * count;
|
---|
31 | break;
|
---|
32 | case GL_FLOAT:
|
---|
33 | params_length = sizeof(GLfloat) * count;
|
---|
34 | break;
|
---|
35 | #if 0
|
---|
36 | case GL_DOUBLE:
|
---|
37 | params_length = sizeof(GLdouble) * count;
|
---|
38 | break;
|
---|
39 | #endif
|
---|
40 | default:
|
---|
41 | __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
42 | "crPackChromiumParametervCR(bad type)" );
|
---|
43 | return;
|
---|
44 | }
|
---|
45 |
|
---|
46 | packet_length = header_length + params_length;
|
---|
47 |
|
---|
48 | CR_GET_BUFFERED_POINTER(pc, packet_length );
|
---|
49 | WRITE_DATA( 0, GLint, packet_length );
|
---|
50 | WRITE_DATA( 4, GLenum, CR_CHROMIUMPARAMETERVCR_EXTEND_OPCODE );
|
---|
51 | WRITE_DATA( 8, GLenum, target );
|
---|
52 | WRITE_DATA( 12, GLenum, type );
|
---|
53 | WRITE_DATA( 16, GLsizei, count );
|
---|
54 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
55 |
|
---|
56 | pos = header_length;
|
---|
57 |
|
---|
58 | switch (type) {
|
---|
59 | case GL_BYTE:
|
---|
60 | case GL_UNSIGNED_BYTE:
|
---|
61 | for (i = 0; i < count; i++, pos += sizeof(GLbyte)) {
|
---|
62 | WRITE_DATA( pos, GLbyte, ((GLbyte *) values)[i]);
|
---|
63 | }
|
---|
64 | break;
|
---|
65 | case GL_SHORT:
|
---|
66 | case GL_UNSIGNED_SHORT:
|
---|
67 | for (i = 0; i < count; i++, pos += sizeof(GLshort)) {
|
---|
68 | WRITE_DATA( pos, GLshort, ((GLshort *) values)[i]);
|
---|
69 | }
|
---|
70 | break;
|
---|
71 | case GL_INT:
|
---|
72 | case GL_UNSIGNED_INT:
|
---|
73 | for (i = 0; i < count; i++, pos += sizeof(GLint)) {
|
---|
74 | WRITE_DATA( pos, GLint, ((GLint *) values)[i]);
|
---|
75 | }
|
---|
76 | break;
|
---|
77 | case GL_FLOAT:
|
---|
78 | for (i = 0; i < count; i++, pos += sizeof(GLfloat)) {
|
---|
79 | WRITE_DATA( pos, GLfloat, ((GLfloat *) values)[i]);
|
---|
80 | }
|
---|
81 | break;
|
---|
82 | #if 0
|
---|
83 | case GL_DOUBLE:
|
---|
84 | for (i = 0; i < count; i++) {
|
---|
85 | WRITE_foo_DATA( sizeof(int) + 12, GLdouble, ((GLdouble *) values)[i]);
|
---|
86 | }
|
---|
87 | break;
|
---|
88 | #endif
|
---|
89 | default:
|
---|
90 | __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
|
---|
91 | "crPackChromiumParametervCR(bad type)" );
|
---|
92 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
93 | return;
|
---|
94 | }
|
---|
95 | CR_UNLOCK_PACKER_CONTEXT(pc);
|
---|
96 | }
|
---|
97 |
|
---|
98 | void PACK_APIENTRY crPackDeleteQueriesARB(GLsizei n, const GLuint * ids)
|
---|
99 | {
|
---|
100 | unsigned char *data_ptr;
|
---|
101 | int packet_length = sizeof(GLenum)+sizeof(n)+n*sizeof(*ids);
|
---|
102 | if (!ids) return;
|
---|
103 | data_ptr = (unsigned char *) crPackAlloc(packet_length);
|
---|
104 | WRITE_DATA(0, GLenum, CR_DELETEQUERIESARB_EXTEND_OPCODE);
|
---|
105 | WRITE_DATA(4, GLsizei, n);
|
---|
106 | crMemcpy(data_ptr + 8, ids, n*sizeof(*ids));
|
---|
107 | crHugePacket(CR_EXTEND_OPCODE, data_ptr);
|
---|
108 | crPackFree(data_ptr);
|
---|
109 | }
|
---|