Commit 4d8d0f03 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

Added support for multi-texturing.

parent 228f22e9
......@@ -162,7 +162,9 @@ convert_tex_address_to_GL(D3DTEXTUREADDRESS dwState)
HRESULT
gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3ddev, DWORD stage) {
IDirect3DTextureGLImpl *gl_surf_ptr = (IDirect3DTextureGLImpl *) surf_ptr->tex_private;
IDirect3DDeviceGLImpl *gl_d3ddev = (IDirect3DDeviceGLImpl *) d3ddev;
BOOLEAN changed = FALSE;
GLenum unit = GL_TEXTURE0_WINE + stage;
if (surf_ptr->mipmap_level != 0) {
WARN(" application activating a sub-level of the mipmapping chain (level %d) !\n", surf_ptr->mipmap_level);
......@@ -189,6 +191,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
}
}
}
if (unit != gl_d3ddev->current_active_tex_unit) {
GL_extensions.glActiveTexture(unit);
gl_d3ddev->current_active_tex_unit = unit;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_mip_level);
changed = TRUE;
}
......@@ -196,6 +202,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
if ((gl_surf_ptr->tex_parameters == NULL) ||
(gl_surf_ptr->tex_parameters[D3DTSS_MAGFILTER - D3DTSS_ADDRESSU] !=
d3ddev->state_block.texture_stage_state[stage][D3DTSS_MAGFILTER - 1])) {
if (unit != gl_d3ddev->current_active_tex_unit) {
GL_extensions.glActiveTexture(unit);
gl_d3ddev->current_active_tex_unit = unit;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
convert_mag_filter_to_GL(d3ddev->state_block.texture_stage_state[stage][D3DTSS_MAGFILTER - 1]));
changed = TRUE;
......@@ -205,6 +215,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
d3ddev->state_block.texture_stage_state[stage][D3DTSS_MINFILTER - 1]) ||
(gl_surf_ptr->tex_parameters[D3DTSS_MIPFILTER - D3DTSS_ADDRESSU] !=
d3ddev->state_block.texture_stage_state[stage][D3DTSS_MIPFILTER - 1])) {
if (unit != gl_d3ddev->current_active_tex_unit) {
GL_extensions.glActiveTexture(unit);
gl_d3ddev->current_active_tex_unit = unit;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
convert_min_filter_to_GL(d3ddev->state_block.texture_stage_state[stage][D3DTSS_MINFILTER - 1],
d3ddev->state_block.texture_stage_state[stage][D3DTSS_MIPFILTER - 1]));
......@@ -213,6 +227,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
if ((gl_surf_ptr->tex_parameters == NULL) ||
(gl_surf_ptr->tex_parameters[D3DTSS_ADDRESSU - D3DTSS_ADDRESSU] !=
d3ddev->state_block.texture_stage_state[stage][D3DTSS_ADDRESSU - 1])) {
if (unit != gl_d3ddev->current_active_tex_unit) {
GL_extensions.glActiveTexture(unit);
gl_d3ddev->current_active_tex_unit = unit;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
convert_tex_address_to_GL(d3ddev->state_block.texture_stage_state[stage][D3DTSS_ADDRESSU - 1]));
changed = TRUE;
......@@ -220,6 +238,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
if ((gl_surf_ptr->tex_parameters == NULL) ||
(gl_surf_ptr->tex_parameters[D3DTSS_ADDRESSV - D3DTSS_ADDRESSU] !=
d3ddev->state_block.texture_stage_state[stage][D3DTSS_ADDRESSV - 1])) {
if (unit != gl_d3ddev->current_active_tex_unit) {
GL_extensions.glActiveTexture(unit);
gl_d3ddev->current_active_tex_unit = unit;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
convert_tex_address_to_GL(d3ddev->state_block.texture_stage_state[stage][D3DTSS_ADDRESSV - 1]));
changed = TRUE;
......@@ -233,6 +255,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
color[1] = ((d3ddev->state_block.texture_stage_state[stage][D3DTSS_BORDERCOLOR - 1] >> 8) & 0xFF) / 255.0;
color[2] = ((d3ddev->state_block.texture_stage_state[stage][D3DTSS_BORDERCOLOR - 1] >> 0) & 0xFF) / 255.0;
color[3] = ((d3ddev->state_block.texture_stage_state[stage][D3DTSS_BORDERCOLOR - 1] >> 24) & 0xFF) / 255.0;
if (unit != gl_d3ddev->current_active_tex_unit) {
GL_extensions.glActiveTexture(unit);
gl_d3ddev->current_active_tex_unit = unit;
}
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color);
changed = TRUE;
}
......@@ -265,6 +291,11 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr, IDirect3DDeviceImpl *d3dd
snoop_texture(surf_ptr);
}
if (unit != gl_d3ddev->current_active_tex_unit) {
GL_extensions.glActiveTexture(unit);
gl_d3ddev->current_active_tex_unit = unit;
}
if (upload_surface_to_tex_memory_init(surf_ptr, surf_ptr->mipmap_level, &(gl_surf_ptr->current_internal_format),
gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) == DD_OK) {
upload_surface_to_tex_memory(NULL, 0, 0, &(gl_surf_ptr->surface_ptr));
......
......@@ -57,6 +57,15 @@
#define GL_MIRRORED_REPEAT_WINE 0x8370
#define GL_TEXTURE_FILTER_CONTROL_WINE 0x8500
#define GL_TEXTURE_LOD_BIAS_WINE 0x8501
#define GL_TEXTURE0_WINE 0x84C0
#define GL_TEXTURE1_WINE 0x84C1
#define GL_TEXTURE2_WINE 0x84C2
#define GL_TEXTURE3_WINE 0x84C3
#define GL_TEXTURE4_WINE 0x84C4
#define GL_TEXTURE5_WINE 0x84C5
#define GL_TEXTURE6_WINE 0x84C6
#define GL_TEXTURE7_WINE 0x84C7
#define GL_MAX_TEXTURE_UNITS_WINE 0x84E2
#ifndef GLPRIVATE_NO_REDEFINE
......
......@@ -83,7 +83,7 @@ static BOOL DDRAW_bind_to_opengl( void )
{
char *glname = SONAME_LIBGL;
BOOL ret_value;
gl_handle = wine_dlopen(glname, RTLD_NOW, NULL, 0);
if (!gl_handle) {
WARN("Wine cannot find the OpenGL graphics library (%s).\n",glname);
......
......@@ -143,6 +143,7 @@ typedef struct IDirect3DDeviceGLImpl
D3DVALUE prev_clear_Z;
BOOLEAN depth_mask, depth_test, alpha_test, stencil_test, cull_face, lighting, blending, fogging;
GLenum current_tex_env;
GLenum current_active_tex_unit;
} IDirect3DDeviceGLImpl;
/* This is for the OpenGL additions... */
......@@ -162,7 +163,12 @@ typedef struct {
typedef struct {
/* Mirrored Repeat */
BOOLEAN mirrored_repeat;
/* Mipmap lod-bias */
BOOLEAN mipmap_lodbias;
/* Multi-texturing */
GLint max_texture_units;
void (*glActiveTexture)(GLenum texture);
void (*glMultiTexCoord2fv)(GLenum target, const GLfloat *v);
} GL_EXTENSIONS_LIST;
extern GL_EXTENSIONS_LIST GL_extensions;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment