Added support for multi-texturing.
[wine/wine64.git] / dlls / ddraw / mesa_private.h
blob9ac00bd84f75fd709597bd1f845a565cc14a0407
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"
27 #ifdef HAVE_OPENGL
29 #include "gl_private.h"
31 /* X11 locking */
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;
42 typedef enum {
43 SURFACE_GL,
44 SURFACE_MEMORY,
45 SURFACE_MEMORY_DIRTY
46 } SURFACE_STATE;
48 /* This structure is used for the 'd3d_private' field of the IDirectDraw structure */
49 typedef struct IDirect3DGLImpl
51 DWORD free_lights;
52 void (*light_released)(IDirectDrawImpl *, GLenum light_num);
53 } IDirect3DGLImpl;
55 typedef struct IDirect3DLightGLImpl
57 struct IDirect3DLightImpl parent;
58 GLenum light_num;
59 } IDirect3DLightGLImpl;
61 /* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */
62 typedef struct IDirect3DTextureGLImpl
64 GLuint tex_name;
65 BOOLEAN loaded; /* For the moment, this is here.. Should be part of surface management though */
67 /* Texture upload management */
68 BOOLEAN initial_upload_done;
69 SURFACE_STATE dirty_flag;
71 /* This is used to optimize dirty checking in case of mipmapping.
72 Note that a bitmap could have been used but it was not worth the pain as it will be very rare
73 to have only one mipmap level change...
75 The __global_dirty_flag will only be set for the main mipmap level.
77 SURFACE_STATE __global_dirty_flag;
78 SURFACE_STATE *global_dirty_flag;
80 /* This is to optimize the 'per-texture' parameters. */
81 DWORD *tex_parameters;
83 /* Surface optimization */
84 void *surface_ptr;
86 /* Used to detect a change in internal format when going from non-CK texture to CK-ed texture */
87 GLenum current_internal_format;
89 /* This is for now used to override 'standard' surface stuff to be as transparent as possible */
90 void (*final_release)(struct IDirectDrawSurfaceImpl *This);
91 void (*lock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags);
92 void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
93 void (*set_palette)(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* pal);
94 } IDirect3DTextureGLImpl;
96 typedef enum {
97 GL_TRANSFORM_NONE = 0,
98 GL_TRANSFORM_ORTHO,
99 GL_TRANSFORM_NORMAL,
100 GL_TRANSFORM_VERTEXBUFFER
101 } GL_TRANSFORM_STATE;
103 typedef enum {
104 WINE_GL_BUFFER_BACK = 0,
105 WINE_GL_BUFFER_FRONT
106 } WINE_GL_BUFFER_TYPE;
108 typedef struct IDirect3DDeviceGLImpl
110 struct IDirect3DDeviceImpl parent;
112 GLXContext gl_context;
114 /* This stores the textures which are actually bound to the GL context */
115 IDirectDrawSurfaceImpl *current_bound_texture[MAX_TEXTURES];
117 /* The last type of vertex drawn */
118 GL_TRANSFORM_STATE transform_state;
120 /* Used to handle fogging faster... */
121 BYTE fog_table[3 * 0x10000]; /* 3 is for R, G and B
122 0x10000 is 0xFF for the vertex color and
123 0xFF for the fog intensity */
125 Display *display;
126 Drawable drawable;
128 /* Variables used for the flush to frame-buffer code using the texturing code */
129 GLuint unlock_tex;
130 void *surface_ptr;
131 GLenum current_internal_format;
133 /* 0 is back-buffer, 1 is front-buffer */
134 SURFACE_STATE state[2];
135 IDirectDrawSurfaceImpl *lock_surf[2];
136 RECT lock_rect[2];
137 /* This is just here to print-out a nice warning if we have two successive locks */
138 BOOLEAN lock_rect_valid[2];
140 /* This is used to optimize some stuff */
141 DWORD prev_clear_color;
142 DWORD prev_clear_stencil;
143 D3DVALUE prev_clear_Z;
144 BOOLEAN depth_mask, depth_test, alpha_test, stencil_test, cull_face, lighting, blending, fogging;
145 GLenum current_tex_env;
146 GLenum current_active_tex_unit;
147 } IDirect3DDeviceGLImpl;
149 /* This is for the OpenGL additions... */
150 typedef struct {
151 struct IDirect3DVertexBufferImpl parent;
153 DWORD dwVertexTypeDesc;
154 D3DMATRIX world_mat, view_mat, proj_mat;
155 LPVOID vertices;
156 } IDirect3DVertexBufferGLImpl;
158 /* This is for GL extension support.
160 This can contain either only a boolean if no function pointer exists or a set
161 of function pointers.
163 typedef struct {
164 /* Mirrored Repeat */
165 BOOLEAN mirrored_repeat;
166 /* Mipmap lod-bias */
167 BOOLEAN mipmap_lodbias;
168 /* Multi-texturing */
169 GLint max_texture_units;
170 void (*glActiveTexture)(GLenum texture);
171 void (*glMultiTexCoord2fv)(GLenum target, const GLfloat *v);
172 } GL_EXTENSIONS_LIST;
173 extern GL_EXTENSIONS_LIST GL_extensions;
175 /* All non-static functions 'exported' by various sub-objects */
176 extern HRESULT direct3d_create(IDirectDrawImpl *This);
177 extern HRESULT d3dtexture_create(IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surf, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main_surf);
178 extern HRESULT d3dlight_create(IDirect3DLightImpl **obj, IDirectDrawImpl *d3d, GLenum light_num);
179 extern HRESULT d3dexecutebuffer_create(IDirect3DExecuteBufferImpl **obj, IDirectDrawImpl *d3d, IDirect3DDeviceImpl *d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
180 extern HRESULT d3dmaterial_create(IDirect3DMaterialImpl **obj, IDirectDrawImpl *d3d);
181 extern HRESULT d3dviewport_create(IDirect3DViewportImpl **obj, IDirectDrawImpl *d3d);
182 extern HRESULT d3dvertexbuffer_create(IDirect3DVertexBufferImpl **obj, IDirectDrawImpl *d3d, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc, DWORD dwFlags);
183 extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface);
185 /* Used for Direct3D to request the device to enumerate itself */
186 extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) ;
187 extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ;
188 extern HRESULT d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
190 /* Used by the DLL init routine to set-up the GL context and stuff properly */
191 extern BOOL d3ddevice_init_at_startup(void *gl_handle);
193 /* Used to upload the texture */
194 extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl *d3ddev, DWORD stage) ;
196 /* Used to set-up our orthographic projection */
197 extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ;
199 /* Rendering state management functions */
200 extern void set_render_state(IDirect3DDeviceImpl* This, D3DRENDERSTATETYPE dwRenderStateType, STATEBLOCK *lpStateBlock);
201 extern void store_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, DWORD dwRenderState, STATEBLOCK* lpStateBlock);
202 extern void get_render_state(IDirect3DDeviceImpl *This, D3DRENDERSTATETYPE dwRenderStateType, LPDWORD lpdwRenderState, STATEBLOCK* lpStateBlock);
203 extern void apply_render_state(IDirect3DDeviceImpl* This, STATEBLOCK* lpStateBlock);
205 /* Memory to texture conversion code. Split in three functions to do some optimizations. */
206 extern HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surface, GLuint level, GLenum *prev_internal_format,
207 BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height);
208 extern HRESULT upload_surface_to_tex_memory(RECT *rect, DWORD xoffset, DWORD yoffset, void **temp_buffer);
209 extern HRESULT upload_surface_to_tex_memory_release(void);
211 /* Some utilities functions needed to be shared.. */
212 extern GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState) ;
214 #endif /* HAVE_OPENGL */
216 #endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */