Beginning of state block.
[wine] / dlls / ddraw / mesa_private.h
1 /* MESA private include file
2  * Copyright (c) 1998 Lionel ULMER
3  *
4  * This file contains all structures that are not exported
5  * through d3d.h and all common macros.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #ifndef __GRAPHICS_WINE_MESA_PRIVATE_H
23 #define __GRAPHICS_WINE_MESA_PRIVATE_H
24
25 #include "d3d_private.h"
26
27 #ifdef HAVE_OPENGL
28
29 #undef APIENTRY
30 #undef CALLBACK
31 #undef WINAPI
32
33 #define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */
34 #include <GL/gl.h>
35 #include <GL/glx.h>
36 #ifdef HAVE_GL_GLEXT_H
37 # include <GL/glext.h>
38 #endif
39 #undef  XMD_H
40
41 #undef APIENTRY
42 #undef CALLBACK
43 #undef WINAPI
44
45 /* Redefines the constants */
46 #define CALLBACK    __stdcall
47 #define WINAPI      __stdcall
48 #define APIENTRY    WINAPI
49
50 /* X11 locking */
51
52 extern void (*wine_tsx11_lock_ptr)(void);
53 extern void (*wine_tsx11_unlock_ptr)(void);
54
55 /* As GLX relies on X, this is needed */
56 #define ENTER_GL() wine_tsx11_lock_ptr()
57 #define LEAVE_GL() wine_tsx11_unlock_ptr()
58
59 extern const GUID IID_D3DDEVICE_OpenGL;
60
61 typedef struct render_state {
62     /* This is used for the device mode */
63     GLenum src, dst;
64     /* This is used for textures */
65     GLenum mag, min;
66
67     /* This is needed for the Alpha stuff */
68     GLenum alpha_func;
69     GLclampf alpha_ref;
70     BOOLEAN alpha_blend_enable;
71
72     /* This is needed for the stencil stuff */
73     GLint stencil_ref;
74     GLuint stencil_mask;
75     GLenum stencil_func;
76     BOOLEAN stencil_enable;
77     GLenum stencil_fail, stencil_zfail, stencil_pass;
78   
79     /* This is needed for proper lighting */
80     BOOLEAN lighting_enable, specular_enable;
81     D3DMATERIALCOLORSOURCE color_diffuse, color_specular, color_ambient, color_emissive;
82
83     /* This is needed to re-enable fogging when XYZRHW and XYZ primitives are mixed */
84     BOOLEAN fog_on;
85 } RenderState;
86
87 typedef struct IDirect3DGLImpl
88 {
89     struct IDirect3DImpl parent;
90     DWORD free_lights;
91     void (*light_released)(IDirect3DImpl *, GLenum light_num);
92 } IDirect3DGLImpl;
93
94 typedef struct IDirect3DLightGLImpl
95 {
96     struct IDirect3DLightImpl parent;
97     GLenum light_num;
98 } IDirect3DLightGLImpl;
99
100 /* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */
101 typedef struct IDirect3DTextureGLImpl
102 {
103     GLuint tex_name;
104     BOOLEAN loaded; /* For the moment, this is here.. Should be part of surface management though */
105     BOOLEAN first_unlock;
106     /* This is for now used to override 'standard' surface stuff to be as transparent as possible */
107     void (*final_release)(struct IDirectDrawSurfaceImpl *This);
108     void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
109     void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
110     void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
111 } IDirect3DTextureGLImpl;
112
113 typedef enum {
114     GL_TRANSFORM_NONE = 0,
115     GL_TRANSFORM_ORTHO,
116     GL_TRANSFORM_NORMAL,
117     GL_TRANSFORM_VERTEXBUFFER
118 } GL_TRANSFORM_STATE;
119
120 typedef struct IDirect3DDeviceGLImpl
121 {
122     struct IDirect3DDeviceImpl parent;
123     
124     GLXContext gl_context;
125
126     /* The current render state */
127     RenderState render_state;
128
129     /* The last type of vertex drawn */
130     GL_TRANSFORM_STATE transform_state;
131
132     Display  *display;
133     Drawable drawable;
134 } IDirect3DDeviceGLImpl;
135
136 /* This is for the OpenGL additions... */
137 typedef struct {
138     struct IDirect3DVertexBufferImpl parent;
139
140     DWORD dwVertexTypeDesc;
141     D3DMATRIX world_mat, view_mat, proj_mat;
142     LPVOID vertices;
143 } IDirect3DVertexBufferGLImpl;
144
145 /* All non-static functions 'exported' by various sub-objects */
146 extern HRESULT direct3d_create(IDirect3DImpl **obj, IDirectDrawImpl *ddraw);
147 extern HRESULT d3dtexture_create(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
148 extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirect3DImpl *d3d, GLenum light_num);
149 extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirect3DImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
150 extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirect3DImpl *d3d);
151 extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirect3DImpl *d3d);
152 extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirect3DImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags);
153 extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *surface);
154
155 /* Used for Direct3D to request the device to enumerate itself */
156 extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) ;
157 extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
158 extern HRESULT d3ddevice_find(IDirect3DImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
159
160 /* Common functions defined in d3dcommon.c */
161 void set_render_state(IDirect3DDeviceGLImpl* This,
162                       D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState);
163 void store_render_state(D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState,
164                         STATEBLOCK* lpStateBlock);
165 void get_render_state(D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState,
166                       STATEBLOCK* lpStateBlock);
167 void apply_render_state(IDirect3DDeviceGLImpl* This, STATEBLOCK* lpStateBlock);
168
169 /* This structure contains all the function pointers to OpenGL extensions
170    that are used by Wine */
171 typedef struct {
172   void (*ptr_ColorTableEXT) (GLenum target, GLenum internalformat,
173                              GLsizei width, GLenum format, GLenum type, const GLvoid *table);
174 } Mesa_DeviceCapabilities;
175
176 #endif /* HAVE_OPENGL */
177
178 #endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */