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
51 int dummy
; /* Empty for the moment */
54 /* This structure is used for the 'private' field of the IDirectDrawSurfaceImpl structure */
55 typedef struct IDirect3DTextureGLImpl
58 BOOLEAN loaded
; /* For the moment, this is here.. Should be part of surface management though */
59 IDirectDrawSurfaceImpl
*main
; /* Pointer to the 'main' surface of the mip-map set */
61 /* Texture upload management */
62 BOOLEAN initial_upload_done
;
63 SURFACE_STATE dirty_flag
;
65 /* This is used to optimize dirty checking in case of mipmapping.
66 Note that a bitmap could have been used but it was not worth the pain as it will be very rare
67 to have only one mipmap level change...
69 The __global_dirty_flag will only be set for the main mipmap level.
71 SURFACE_STATE __global_dirty_flag
;
72 SURFACE_STATE
*global_dirty_flag
;
74 /* This is to optimize the 'per-texture' parameters. */
75 DWORD
*tex_parameters
;
77 /* Surface optimization */
80 /* Used to detect a change in internal format when going from non-CK texture to CK-ed texture */
81 GLenum current_internal_format
;
83 /* This is for now used to override 'standard' surface stuff to be as transparent as possible */
84 void (*final_release
)(struct IDirectDrawSurfaceImpl
*This
);
85 void (*lock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
, DWORD dwFlags
);
86 void (*unlock_update
)(IDirectDrawSurfaceImpl
* This
, LPCRECT pRect
);
87 void (*set_palette
)(IDirectDrawSurfaceImpl
* This
, IDirectDrawPaletteImpl
* pal
);
88 } IDirect3DTextureGLImpl
;
91 GL_TRANSFORM_NONE
= 0,
94 GL_TRANSFORM_VERTEXBUFFER
98 WINE_GL_BUFFER_BACK
= 0,
100 } WINE_GL_BUFFER_TYPE
;
102 typedef struct IDirect3DDeviceGLImpl
104 struct IDirect3DDeviceImpl parent
;
106 GLXContext gl_context
;
108 /* This stores the textures which are actually bound to the GL context */
109 IDirectDrawSurfaceImpl
*current_bound_texture
[MAX_TEXTURES
];
111 /* The last type of vertex drawn */
112 GL_TRANSFORM_STATE transform_state
;
114 /* Used to handle fogging faster... */
115 BYTE fog_table
[3 * 0x10000]; /* 3 is for R, G and B
116 0x10000 is 0xFF for the vertex color and
117 0xFF for the fog intensity */
122 /* Variables used for the flush to frame-buffer code using the texturing code */
125 GLenum current_internal_format
;
127 /* 0 is back-buffer, 1 is front-buffer */
128 SURFACE_STATE state
[2];
129 IDirectDrawSurfaceImpl
*lock_surf
[2];
131 /* This is just here to print-out a nice warning if we have two successive locks */
132 BOOLEAN lock_rect_valid
[2];
134 /* This is used to optimize some stuff */
135 DWORD prev_clear_color
;
136 DWORD prev_clear_stencil
;
137 D3DVALUE prev_clear_Z
;
138 BOOLEAN depth_mask
, depth_test
, alpha_test
, stencil_test
, cull_face
, lighting
, blending
, fogging
;
139 GLenum current_alpha_test_func
;
140 GLclampf current_alpha_test_ref
;
141 GLenum current_tex_env
;
142 GLenum current_active_tex_unit
;
143 } IDirect3DDeviceGLImpl
;
145 /* This is for the OpenGL additions... */
147 struct IDirect3DVertexBufferImpl parent
;
149 DWORD dwVertexTypeDesc
;
150 D3DMATRIX world_mat
, view_mat
, proj_mat
;
152 } IDirect3DVertexBufferGLImpl
;
154 /* This is for GL extension support.
156 This can contain either only a boolean if no function pointer exists or a set
157 of function pointers.
160 /* Mirrored Repeat */
161 BOOLEAN mirrored_repeat
;
162 /* Mipmap lod-bias */
163 BOOLEAN mipmap_lodbias
;
164 /* Multi-texturing */
165 GLint max_texture_units
;
166 void (*glActiveTexture
)(GLenum texture
);
167 void (*glMultiTexCoord
[4])(GLenum target
, const GLfloat
*v
);
168 void (*glClientActiveTexture
)(GLenum texture
);
169 /* S3TC/DXTN compressed texture */
170 BOOLEAN s3tc_compressed_texture
;
171 void (*glCompressedTexImage2D
)(GLenum target
, GLint level
, GLenum internalformat
, GLsizei width
,
172 GLsizei height
, GLint border
, GLsizei imageSize
, const GLvoid
*data
);
173 void (*glCompressedTexSubImage2D
)(GLenum target
, GLint level
, GLint xoffset
, GLint yoffset
,
174 GLsizei width
, GLsizei height
, GLsizei imageSize
, const GLvoid
*data
);
175 } GL_EXTENSIONS_LIST
;
176 extern GL_EXTENSIONS_LIST GL_extensions
;
178 /* All non-static functions 'exported' by various sub-objects */
179 extern HRESULT
direct3d_create(IDirectDrawImpl
*This
);
180 extern HRESULT
d3dtexture_create(IDirectDrawImpl
*d3d
, IDirectDrawSurfaceImpl
*surf
, BOOLEAN at_creation
, IDirectDrawSurfaceImpl
*main_surf
);
181 extern HRESULT
d3dlight_create(IDirect3DLightImpl
**obj
, IDirectDrawImpl
*d3d
);
182 extern HRESULT
d3dexecutebuffer_create(IDirect3DExecuteBufferImpl
**obj
, IDirectDrawImpl
*d3d
, IDirect3DDeviceImpl
*d3ddev
, LPD3DEXECUTEBUFFERDESC lpDesc
);
183 extern HRESULT
d3dmaterial_create(IDirect3DMaterialImpl
**obj
, IDirectDrawImpl
*d3d
);
184 extern HRESULT
d3dviewport_create(IDirect3DViewportImpl
**obj
, IDirectDrawImpl
*d3d
);
185 extern HRESULT
d3dvertexbuffer_create(IDirect3DVertexBufferImpl
**obj
, IDirectDrawImpl
*d3d
, LPD3DVERTEXBUFFERDESC lpD3DVertBufDesc
, DWORD dwFlags
);
186 extern HRESULT
d3ddevice_create(IDirect3DDeviceImpl
**obj
, IDirectDrawImpl
*d3d
, IDirectDrawSurfaceImpl
*surface
, int version
);
188 /* Used for Direct3D to request the device to enumerate itself */
189 extern HRESULT
d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb
, LPVOID context
, DWORD version
) ;
190 extern HRESULT
d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb
, LPVOID context
) ;
191 extern HRESULT
d3ddevice_find(IDirectDrawImpl
*d3d
, LPD3DFINDDEVICESEARCH lpD3DDFS
, LPD3DFINDDEVICERESULT lplpD3DDevice
);
193 /* Used by the DLL init routine to set-up the GL context and stuff properly */
194 extern BOOL
d3ddevice_init_at_startup(void *gl_handle
);
196 /* Used to upload the texture */
197 extern HRESULT
gltex_upload_texture(IDirectDrawSurfaceImpl
*This
, IDirect3DDeviceImpl
*d3ddev
, DWORD stage
) ;
199 /* Used to get the texture name */
200 extern GLuint
gltex_get_tex_name(IDirectDrawSurfaceImpl
*This
) ;
202 /* Used to set-up our orthographic projection */
203 extern void d3ddevice_set_ortho(IDirect3DDeviceImpl
*This
) ;
205 /* Rendering state management functions */
206 extern void set_render_state(IDirect3DDeviceImpl
* This
, D3DRENDERSTATETYPE dwRenderStateType
, STATEBLOCK
*lpStateBlock
);
207 extern void store_render_state(IDirect3DDeviceImpl
*This
, D3DRENDERSTATETYPE dwRenderStateType
, DWORD dwRenderState
, STATEBLOCK
* lpStateBlock
);
208 extern void get_render_state(IDirect3DDeviceImpl
*This
, D3DRENDERSTATETYPE dwRenderStateType
, LPDWORD lpdwRenderState
, STATEBLOCK
* lpStateBlock
);
209 extern void apply_render_state(IDirect3DDeviceImpl
* This
, STATEBLOCK
* lpStateBlock
);
211 /* Memory to texture conversion code. Split in three functions to do some optimizations. */
212 extern HRESULT
upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl
*surface
, GLuint level
, GLenum
*prev_internal_format
,
213 BOOLEAN need_to_alloc
, BOOLEAN need_alpha_ck
, DWORD tex_width
, DWORD tex_height
);
214 extern HRESULT
upload_surface_to_tex_memory(RECT
*rect
, DWORD xoffset
, DWORD yoffset
, void **temp_buffer
);
215 extern HRESULT
upload_surface_to_tex_memory_release(void);
217 /* Some utilities functions needed to be shared.. */
218 extern GLenum
convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState
) ;
220 #endif /* HAVE_OPENGL */
222 #endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */