summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/include/state/cr_client.h
blob: a727f260fe8394942ece682ab4ac417dfd704acb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/* Copyright (c) 2001, Stanford University
 * All rights reserved.
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#ifndef CR_STATE_CLIENT_H
#define CR_STATE_CLIENT_H

#include "state/cr_statetypes.h"
#include "state/cr_limits.h"
#include "state/cr_bufferobject.h"
#include "cr_bits.h"

#include <iprt/cdefs.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    CRbitvalue  dirty[CR_MAX_BITARRAY];
    /* pixel pack/unpack */
    CRbitvalue  pack[CR_MAX_BITARRAY];
    CRbitvalue  unpack[CR_MAX_BITARRAY];
    /* vertex array */
    CRbitvalue  enableClientState[CR_MAX_BITARRAY];
    CRbitvalue  clientPointer[CR_MAX_BITARRAY];
    CRbitvalue  *v; /* vertex */
    CRbitvalue  *n; /* normal */
    CRbitvalue  *c; /* color */
    CRbitvalue  *i; /* index */
    CRbitvalue  *t[CR_MAX_TEXTURE_UNITS]; /* texcoord */
    CRbitvalue  *e; /* edgeflag */
    CRbitvalue  *s; /* secondary color */
    CRbitvalue  *f; /* fog coord */
#ifdef CR_NV_vertex_program
    CRbitvalue  *a[CR_MAX_VERTEX_ATTRIBS]; /* NV_vertex_program */
#endif
} CRClientBits;

/*
 * NOTE!!!! If you change this structure, search through the code for
 * occurrences of 'defaultPacking' and fix the static initializations!!!!
 */
typedef struct {
    GLint       rowLength;
    GLint       skipRows;
    GLint       skipPixels;
    GLint       alignment;
    GLint       imageHeight;
    GLint       skipImages;
    GLboolean   swapBytes;
    GLboolean   psLSBFirst; /* don't conflict with crap from Xlib.h */
} CRPixelPackState;

typedef struct {
    unsigned char *p;
    GLint size;
    GLint type;
    GLint stride;
    GLboolean enabled;
    GLboolean normalized; /* Added with GL_ARB_vertex_program */
    int bytesPerIndex;
#ifdef CR_ARB_vertex_buffer_object
    CRBufferObject *buffer;
#endif
#ifdef CR_EXT_compiled_vertex_array
    GLboolean locked;
    unsigned char *prevPtr;
    GLint   prevStride;
#endif
} CRClientPointer;

typedef struct {
    CRClientPointer v;                         /* vertex */
    CRClientPointer n;                         /* normal */
    CRClientPointer c;                         /* color */
    CRClientPointer i;                         /* color index */
    CRClientPointer t[CR_MAX_TEXTURE_UNITS];   /* texcoords */
    CRClientPointer e;                         /* edge flags */
    CRClientPointer s;                         /* secondary color */
    CRClientPointer f;                         /* fog coord */
#ifdef CR_NV_vertex_program
    CRClientPointer a[CR_MAX_VERTEX_ATTRIBS];  /* vertex attribs */
#endif
#ifdef CR_NV_vertex_array_range
    GLboolean arrayRange;
    GLboolean arrayRangeValid;
    void *arrayRangePointer;
    GLuint arrayRangeLength;
#endif
#ifdef CR_EXT_compiled_vertex_array
    GLint lockFirst;
    GLint lockCount;
    GLboolean locked;
# ifdef IN_GUEST
    GLboolean synced;
# endif
#endif
} CRVertexArrays;

#define CRSTATECLIENT_MAX_VERTEXARRAYS (7+CR_MAX_TEXTURE_UNITS+CR_MAX_VERTEX_ATTRIBS)

typedef struct {
    /* pixel pack/unpack */
    CRPixelPackState pack;
    CRPixelPackState unpack;

    CRVertexArrays array;

    GLint curClientTextureUnit;

    /* state stacks (glPush/PopClientState) */
    GLint attribStackDepth;
    CRbitvalue pushMaskStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];

    GLint pixelStoreStackDepth;
    CRPixelPackState pixelPackStoreStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];
    CRPixelPackState pixelUnpackStoreStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];

    GLint vertexArrayStackDepth;
    CRVertexArrays vertexArrayStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];
} CRClientState;

extern const CRPixelPackState crStateNativePixelPacking;

struct CRContext;

DECLEXPORT(void) crStateClientInitBits(CRClientBits *c);
DECLEXPORT(void) crStateClientDestroyBits(CRClientBits *c);
DECLEXPORT(void) crStateClientInit(struct CRContext *g);
DECLEXPORT(void) crStateClientDestroy(struct CRContext *g);

DECLEXPORT(GLboolean) crStateUseServerArrays(void);
DECLEXPORT(GLboolean) crStateUseServerArrayElements(void);
DECLEXPORT(CRClientPointer*) crStateGetClientPointerByIndex(int index, CRVertexArrays *array);

#ifdef __cplusplus
}
#endif

#endif /* CR_CLIENT_H */