VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_bufferobject.c@ 21422

Last change on this file since 21422 was 21422, checked in by vboxsync, 15 years ago

crOpenGL: fix VBOs support on 32/64 or 64/32 guest/host combinations

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 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#include "cr_string.h"
10#include "cr_version.h"
11
12
13void PACK_APIENTRY
14crPackMapBufferARB( GLenum target, GLenum access,
15 void * return_value, int * writeback )
16{
17 (void)writeback;
18 (void)return_value;
19 (void)target;
20 (void)access;
21 crWarning("Can't pack MapBufferARB command!");
22}
23
24
25void PACK_APIENTRY
26crPackUnmapBufferARB( GLenum target, GLboolean* return_value, int * writeback )
27{
28 (void)target;
29 (void)return_value;
30 (void)writeback;
31 crWarning("Can't pack UnmapBufferARB command!");
32}
33
34
35void PACK_APIENTRY
36crPackBufferDataARB( GLenum target, GLsizeiptrARB size,
37 const GLvoid * data, GLenum usage )
38{
39 unsigned char *data_ptr, *start_ptr;
40 int packet_length;
41
42 packet_length = sizeof(GLenum)
43 + sizeof(target) + sizeof(GLuint) + sizeof(usage) + sizeof(GLboolean);
44
45 /*Note: it's valid to pass a NULL pointer here, which tells GPU drivers to allocate memory for the VBO*/
46 if (data) packet_length += size;
47
48 start_ptr = data_ptr = (unsigned char *) crPackAlloc( packet_length );
49
50 WRITE_DATA_AI(GLenum, CR_BUFFERDATAARB_EXTEND_OPCODE);
51 WRITE_DATA_AI(GLenum, target);
52 WRITE_DATA_AI(GLuint, (GLuint) size);
53 WRITE_DATA_AI(GLenum, usage);
54 WRITE_DATA_AI(GLboolean, (GLboolean) (data!=NULL));
55 if (data)
56 crMemcpy(data_ptr, data, size);
57
58 crHugePacket( CR_EXTEND_OPCODE, start_ptr );
59 crPackFree( start_ptr );
60}
61
62
63void PACK_APIENTRY
64crPackBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size,
65 const GLvoid * data )
66{
67 unsigned char *data_ptr, *start_ptr;
68 int packet_length;
69
70 if (!data)
71 return;
72
73 packet_length = sizeof(GLenum)
74 + sizeof(target) + sizeof(GLuint) + sizeof(GLuint) + size;
75
76 start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length);
77 WRITE_DATA_AI(GLenum, CR_BUFFERSUBDATAARB_EXTEND_OPCODE);
78 WRITE_DATA_AI(GLenum, target);
79 WRITE_DATA_AI(GLuint, (GLuint) offset);
80 WRITE_DATA_AI(GLuint, (GLuint) size);
81 crMemcpy(data_ptr, data, size);
82
83 crHugePacket(CR_EXTEND_OPCODE, start_ptr);
84 crPackFree(start_ptr);
85}
86
87void PACK_APIENTRY
88crPackGetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data, int * writeback )
89{
90 GET_PACKER_CONTEXT(pc);
91 unsigned char *data_ptr;
92 (void) pc;
93 GET_BUFFERED_POINTER( pc, 36 );
94 WRITE_DATA( 0, GLint, 36 );
95 WRITE_DATA( 4, GLenum, CR_GETBUFFERSUBDATAARB_EXTEND_OPCODE );
96 WRITE_DATA( 8, GLenum, target );
97 WRITE_DATA( 12, GLuint, (GLuint) offset );
98 WRITE_DATA( 16, GLuint, (GLuint) size );
99 WRITE_NETWORK_POINTER( 20, (void *) data );
100 WRITE_NETWORK_POINTER( 28, (void *) writeback );
101 WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
102}
103
104void PACK_APIENTRY
105crPackDeleteBuffersARB(GLsizei n, const GLuint * buffers)
106{
107 unsigned char *data_ptr;
108 int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*buffers);
109
110 if (!buffers)
111 return;
112
113 data_ptr = (unsigned char *) crPackAlloc(packet_length);
114 WRITE_DATA( 0, GLenum, CR_DELETEBUFFERSARB_EXTEND_OPCODE );
115 WRITE_DATA( 4, GLsizei, n );
116 crMemcpy( data_ptr + 8, buffers, n * sizeof(*buffers) );
117 crHugePacket( CR_EXTEND_OPCODE, data_ptr );
118 crPackFree( data_ptr );
119}
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