1 /* MESA private include file
2 * Copyright (c) 1998 Lionel ULMER
4 * This file contains all structures that are not exported
5 * through d3d.h and all common macros.
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.
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.
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
22 #ifndef __GRAPHICS_WINE_MESA_PRIVATE_H
23 #define __GRAPHICS_WINE_MESA_PRIVATE_H
25 #include "d3d_private.h"
29 #include "gl_private.h"
33 extern void (*wine_tsx11_lock_ptr)(void);
34 extern void (*wine_tsx11_unlock_ptr)(void);
36 /* As GLX relies on X, this is needed */
37 #define ENTER_GL() wine_tsx11_lock_ptr()
38 #define LEAVE_GL() wine_tsx11_unlock_ptr()
40 extern const GUID IID_D3DDEVICE_OpenGL;
48 /* This structure is used for the 'd3d_private' field of the IDirectDraw structure */
49 typedef struct IDirect3DGLImpl
52 void (*light_released)(IDirectDrawImpl *, GLenum light_num);
55 typedef struct IDirect3DLightGLImpl
57 struct IDirect3DLightImpl parent;
59 } IDirect3DLightGLImpl;
61 /* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */
62 typedef struct IDirect3DTextureGLImpl
65 BOOLEAN loaded; /* For the moment, this is here.. Should be part of surface management though */
66 IDirectDrawSurfaceImpl *main; /* Pointer to the 'main' surface of the mip-map set */
68 /* Texture upload management */
69 BOOLEAN initial_upload_done;
70 SURFACE_STATE dirty_flag;
72 /* This is used to optimize dirty checking in case of mipmapping.
73 Note that a bitmap could have been used but it was not worth the pain as it will be very rare
74 to have only one mipmap level change...
76 The __global_dirty_flag will only be set for the main mipmap level.
78 SURFACE_STATE __global_dirty_flag;
79 SURFACE_STATE *global_dirty_flag;
81 /* This is to optimize the 'per-texture' parameters. */
82 DWORD *tex_parameters;
84 /* Surface optimization */
87 /* Used to detect a change in internal format when going from non-CK texture to CK-ed texture */
88 GLenum current_internal_format;
90 /* This is for now used to override 'standard' surface stuff to be as transparent as possible */
91 void (*final_release)(struct IDirectDrawSurfaceImpl *This);
92 void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
93 void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
94 void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
95 } IDirect3DTextureGLImpl;
98 GL_TRANSFORM_NONE = 0,
101 GL_TRANSFORM_VERTEXBUFFER
102 } GL_TRANSFORM_STATE;
105 WINE_GL_BUFFER_BACK = 0,
107 } WINE_GL_BUFFER_TYPE;
109 typedef struct IDirect3DDeviceGLImpl
111 struct IDirect3DDeviceImpl parent;
113 GLXContext gl_context;
115 /* This stores the textures which are actually bound to the GL context */
116 IDirectDrawSurfaceImpl *current_bound_texture[MAX_TEXTURES];
118 /* The last type of vertex drawn */
119 GL_TRANSFORM_STATE transform_state;
121 /* Used to handle fogging faster... */
122 BYTE fog_table[3 * 0x10000]; /* 3 is for R, G and B
123 0x10000 is 0xFF for the vertex color and
124 0xFF for the fog intensity */
129 /* Variables used for the flush to frame-buffer code using the texturing code */
132 GLenum current_internal_format;
134 /* 0 is back-buffer, 1 is front-buffer */
135 SURFACE_STATE state[2];
136 IDirectDrawSurfaceImpl *lock_surf[2];
138 /* This is just here to print-out a nice warning if we have two successive locks */
139 BOOLEAN lock_rect_valid[2];
141 /* This is used to optimize some stuff */
142 DWORD prev_clear_color;
143 DWORD prev_clear_stencil;
144 D3DVALUE prev_clear_Z;
145 BOOLEAN depth_mask, depth_test, alpha_test, stencil_test, cull_face, lighting, blending, fogging;
146 GLenum current_alpha_test_func;
147 GLclampf current_alpha_test_ref;
148 GLenum current_tex_env;
149 GLenum current_active_tex_unit;
150 } IDirect3DDeviceGLImpl;
152 /* This is for the OpenGL additions... */
154 struct IDirect3DVertexBufferImpl parent;
156 DWORD dwVertexTypeDesc;
157 D3DMATRIX world_mat, view_mat, proj_mat;
159 } IDirect3DVertexBufferGLImpl;
161 /* This is for GL extension support.
163 This can contain either only a boolean if no function pointer exists or a set
164 of function pointers.
167 /* Mirrored Repeat */
168 BOOLEAN mirrored_repeat;
169 /* Mipmap lod-bias */
170 BOOLEAN mipmap_lodbias;
171 /* Multi-texturing */
172 GLint max_texture_units;
173 void (*glActiveTexture)(GLenum texture);
174 void (*glMultiTexCoord[4])(GLenum target, const GLfloat *v);
175 void (*glClientActiveTexture)(GLenum texture);
176 /* S3TC/DXTN compressed texture */
177 BOOLEAN s3tc_compressed_texture;
178 void (*glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width,
179 GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
180 void (*glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
181 GLsizei width, GLsizei height, GLsizei imageSize, const GLvoid *data);
182 } GL_EXTENSIONS_LIST;
183 extern GL_EXTENSIONS_LIST GL_extensions;
185 /* All non-static functions 'exported' by various sub-objects */
186 extern HRESULT direct3d_create(IDirectDrawImpl *This);
187 extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
188 extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d, GLenum light_num);
189 extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
190 extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d);
191 extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d);
192 extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags);
193 extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface, int version);
195 /* Used for Direct3D to request the device to enumerate itself */
196 extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) ;
197 extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
198 extern HRESULT d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
200 /* Used by the DLL init routine to set-up the GL context and stuff properly */
201 extern BOOL d3ddevice_init_at_startup(void *gl_handle);
203 /* Used to upload the texture */
204 extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl *d3ddev, DWORD stage) ;
206 /* Used to get the texture name */
207 extern GLuint gltex_get_tex_name(IDirectDrawSurfaceImpl *This) ;
209 /* Used to set-up our orthographic projection */
210 extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
212 /* Rendering state management functions */
213 extern void set_render_state(IDirect3DDeviceImpl* This, D3DRENDERSTATETYPE dwRenderStateType, STATEBLOCK *lpStateBlock);
214 extern void store_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState, STATEBLOCK* lpStateBlock);
215 extern void get_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState, STATEBLOCK* lpStateBlock);
216 extern void apply_render_state(IDirect3DDeviceImpl* This, STATEBLOCK* lpStateBlock);
218 /* Memory to texture conversion code. Split in three functions to do some optimizations. */
219 extern HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surface, GLuint level, GLenum *prev_internal_format,
220 BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height);
221 extern HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer);
222 extern HRESULT upload_surface_to_tex_memory_release(void);
224 /* Some utilities functions needed to be shared.. */
225 extern GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState) ;
227 #endif /* HAVE_OPENGL */
229 #endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */