Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
62d4f41e
Commit
62d4f41e
authored
Jan 02, 2003
by
Lionel Ulmer
Committed by
Alexandre Julliard
Jan 02, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize some code in the texture uploading function.
parent
da66dad0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
161 deletions
+56
-161
d3dtexture.c
dlls/ddraw/d3dtexture.c
+56
-161
No files found.
dlls/ddraw/d3dtexture.c
View file @
62d4f41e
...
@@ -146,6 +146,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
...
@@ -146,6 +146,10 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
#endif
#endif
void
(
*
ptr_ColorTableEXT
)
(
GLenum
target
,
GLenum
internalformat
,
void
(
*
ptr_ColorTableEXT
)
(
GLenum
target
,
GLenum
internalformat
,
GLsizei
width
,
GLenum
format
,
GLenum
type
,
const
GLvoid
*
table
)
=
NULL
;
GLsizei
width
,
GLenum
format
,
GLenum
type
,
const
GLvoid
*
table
)
=
NULL
;
BOOL
upload_done
=
FALSE
;
BOOL
error
=
FALSE
;
GLenum
format
,
pixel_format
;
VOID
*
surface
=
NULL
;
DDSURFACEDESC
*
src_d
=
(
DDSURFACEDESC
*
)
&
(
This
->
surface_desc
);
DDSURFACEDESC
*
src_d
=
(
DDSURFACEDESC
*
)
&
(
This
->
surface_desc
);
...
@@ -174,6 +178,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
...
@@ -174,6 +178,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
if
(
pal
==
NULL
)
{
if
(
pal
==
NULL
)
{
ERR
(
"Palettized texture Loading with a NULL palette !
\n
"
);
ERR
(
"Palettized texture Loading with a NULL palette !
\n
"
);
glBindTexture
(
GL_TEXTURE_2D
,
current_texture
);
return
;
return
;
}
}
/* Get the surface's palette */
/* Get the surface's palette */
...
@@ -206,10 +211,14 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
...
@@ -206,10 +211,14 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
GL_COLOR_INDEX
,
/* texture format */
GL_COLOR_INDEX
,
/* texture format */
GL_UNSIGNED_BYTE
,
/* texture type */
GL_UNSIGNED_BYTE
,
/* texture type */
src_d
->
lpSurface
);
/* the texture */
src_d
->
lpSurface
);
/* the texture */
upload_done
=
TRUE
;
}
else
{
}
else
{
DWORD
*
surface
=
(
DWORD
*
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
src_d
->
dwWidth
*
src_d
->
dwHeight
*
sizeof
(
DWORD
));
DWORD
i
;
DWORD
i
;
BYTE
*
src
=
(
BYTE
*
)
src_d
->
lpSurface
,
*
dst
=
(
BYTE
*
)
surface
;
BYTE
*
src
=
(
BYTE
*
)
src_d
->
lpSurface
,
*
dst
;
surface
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
src_d
->
dwWidth
*
src_d
->
dwHeight
*
sizeof
(
DWORD
));
dst
=
(
BYTE
*
)
surface
;
for
(
i
=
0
;
i
<
src_d
->
dwHeight
*
src_d
->
dwWidth
;
i
++
)
{
for
(
i
=
0
;
i
<
src_d
->
dwHeight
*
src_d
->
dwWidth
;
i
++
)
{
BYTE
color
=
*
src
++
;
BYTE
color
=
*
src
++
;
...
@@ -219,25 +228,8 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
...
@@ -219,25 +228,8 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
*
dst
++
=
table
[
color
][
3
];
*
dst
++
=
table
[
color
][
3
];
}
}
if
(
init_upload
)
format
=
GL_RGBA
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_BYTE
;
This
->
mipmap_level
,
GL_RGBA
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
surface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
surface
);
HeapFree
(
GetProcessHeap
(),
0
,
surface
);
}
}
}
else
if
(
src_d
->
ddpfPixelFormat
.
dwFlags
&
DDPF_RGB
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
dwFlags
&
DDPF_RGB
)
{
/* ************
/* ************
...
@@ -247,84 +239,25 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
...
@@ -247,84 +239,25 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
/* **********************
/* **********************
GL_UNSIGNED_BYTE_3_3_2
GL_UNSIGNED_BYTE_3_3_2
********************** */
********************** */
if
(
init_upload
)
format
=
GL_RGB
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_BYTE_3_3_2
;
This
->
mipmap_level
,
GL_RGB
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE_3_3_2
,
src_d
->
lpSurface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGB
,
GL_UNSIGNED_BYTE_3_3_2
,
src_d
->
lpSurface
);
}
else
if
(
src_d
->
ddpfPixelFormat
.
u1
.
dwRGBBitCount
==
16
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
u1
.
dwRGBBitCount
==
16
)
{
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x00000000
)
{
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x00000000
)
{
if
(
init_upload
)
format
=
GL_RGB
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_SHORT_5_6_5
;
This
->
mipmap_level
,
GL_RGB
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGB
,
GL_UNSIGNED_SHORT_5_6_5
,
src_d
->
lpSurface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGB
,
GL_UNSIGNED_SHORT_5_6_5
,
src_d
->
lpSurface
);
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x00000001
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x00000001
)
{
if
(
init_upload
)
format
=
GL_RGBA
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_SHORT_5_5_5_1
;
This
->
mipmap_level
,
GL_RGBA
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGBA
,
GL_UNSIGNED_SHORT_5_5_5_1
,
src_d
->
lpSurface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGBA
,
GL_UNSIGNED_SHORT_5_5_5_1
,
src_d
->
lpSurface
);
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x0000000F
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x0000000F
)
{
if
(
init_upload
)
format
=
GL_RGBA
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_SHORT_4_4_4_4
;
This
->
mipmap_level
,
GL_RGBA
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGBA
,
GL_UNSIGNED_SHORT_4_4_4_4
,
src_d
->
lpSurface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGBA
,
GL_UNSIGNED_SHORT_4_4_4_4
,
src_d
->
lpSurface
);
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x0000F000
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x0000F000
)
{
/* Move the four Alpha bits... */
/* Move the four Alpha bits... */
WORD
*
surface
=
(
WORD
*
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
src_d
->
dwWidth
*
src_d
->
dwHeight
*
sizeof
(
WORD
));
DWORD
i
;
DWORD
i
;
WORD
*
src
=
(
WORD
*
)
src_d
->
lpSurface
,
*
dst
=
surface
;
WORD
*
src
=
(
WORD
*
)
src_d
->
lpSurface
,
*
dst
;
surface
=
(
WORD
*
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
src_d
->
dwWidth
*
src_d
->
dwHeight
*
sizeof
(
WORD
));
dst
=
surface
;
for
(
i
=
0
;
i
<
src_d
->
dwHeight
*
src_d
->
dwWidth
;
i
++
)
{
for
(
i
=
0
;
i
<
src_d
->
dwHeight
*
src_d
->
dwWidth
;
i
++
)
{
*
dst
++
=
(((
*
src
&
0xFFF0
)
>>
4
)
|
*
dst
++
=
(((
*
src
&
0xFFF0
)
>>
4
)
|
...
@@ -332,101 +265,63 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
...
@@ -332,101 +265,63 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *This, BOOLEAN init_upload) {
src
++
;
src
++
;
}
}
if
(
init_upload
)
format
=
GL_RGBA
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_SHORT_4_4_4_4
;
This
->
mipmap_level
,
GL_RGBA
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGBA
,
GL_UNSIGNED_SHORT_4_4_4_4
,
surface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGBA
,
GL_UNSIGNED_SHORT_4_4_4_4
,
surface
);
HeapFree
(
GetProcessHeap
(),
0
,
surface
);
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x00008000
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
u5
.
dwRGBAlphaBitMask
==
0x00008000
)
{
/* Converting the 1555 format in 5551 packed */
/* Converting the 1555 format in 5551 packed */
WORD
*
surface
=
(
WORD
*
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
src_d
->
dwWidth
*
src_d
->
dwHeight
*
sizeof
(
WORD
));
DWORD
i
;
DWORD
i
;
WORD
*
src
=
(
WORD
*
)
src_d
->
lpSurface
,
*
dst
=
surface
;
WORD
*
src
=
(
WORD
*
)
src_d
->
lpSurface
,
*
dst
;
surface
=
(
WORD
*
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
src_d
->
dwWidth
*
src_d
->
dwHeight
*
sizeof
(
WORD
));
dst
=
(
WORD
*
)
surface
;
for
(
i
=
0
;
i
<
src_d
->
dwHeight
*
src_d
->
dwWidth
;
i
++
)
{
for
(
i
=
0
;
i
<
src_d
->
dwHeight
*
src_d
->
dwWidth
;
i
++
)
{
*
dst
++
=
(((
*
src
&
0x8000
)
>>
15
)
|
*
dst
++
=
(((
*
src
&
0x8000
)
>>
15
)
|
((
*
src
&
0x7FFF
)
<<
1
));
((
*
src
&
0x7FFF
)
<<
1
));
src
++
;
src
++
;
}
}
if
(
init_upload
)
format
=
GL_RGBA
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_SHORT_5_5_5_1
;
This
->
mipmap_level
,
GL_RGBA
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGBA
,
GL_UNSIGNED_SHORT_5_5_5_1
,
surface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGBA
,
GL_UNSIGNED_SHORT_5_5_5_1
,
surface
);
HeapFree
(
GetProcessHeap
(),
0
,
surface
);
}
else
{
}
else
{
ERR
(
"Unhandled texture format (bad Aplha channel for a 16 bit texture)
\n
"
);
ERR
(
"Unhandled texture format (bad Aplha channel for a 16 bit texture)
\n
"
);
error
=
TRUE
;
}
}
}
else
if
(
src_d
->
ddpfPixelFormat
.
u1
.
dwRGBBitCount
==
24
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
u1
.
dwRGBBitCount
==
24
)
{
if
(
init_upload
)
format
=
GL_RGB
;
glTexImage2D
(
GL_TEXTURE_2D
,
pixel_format
=
GL_UNSIGNED_BYTE
;
This
->
mipmap_level
,
GL_RGB
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
src_d
->
lpSurface
);
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGB
,
GL_UNSIGNED_BYTE
,
src_d
->
lpSurface
);
}
else
if
(
src_d
->
ddpfPixelFormat
.
u1
.
dwRGBBitCount
==
32
)
{
}
else
if
(
src_d
->
ddpfPixelFormat
.
u1
.
dwRGBBitCount
==
32
)
{
format
=
GL_RGBA
;
pixel_format
=
GL_UNSIGNED_BYTE
;
}
else
{
ERR
(
"Unhandled texture format (bad RGB count)
\n
"
);
error
=
TRUE
;
}
}
else
{
ERR
(
"Unhandled texture format (neither RGB nor INDEX)
\n
"
);
error
=
TRUE
;
}
if
((
upload_done
==
FALSE
)
&&
(
error
==
FALSE
))
{
if
(
init_upload
)
if
(
init_upload
)
glTexImage2D
(
GL_TEXTURE_2D
,
glTexImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
This
->
mipmap_level
,
GL_RGBA
,
format
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
0
,
0
,
GL_RGBA
,
format
,
GL_UNSIGNED_BYTE
,
pixel_format
,
src_d
->
lpS
urface
);
surface
==
NULL
?
src_d
->
lpSurface
:
s
urface
);
else
else
glTexSubImage2D
(
GL_TEXTURE_2D
,
glTexSubImage2D
(
GL_TEXTURE_2D
,
This
->
mipmap_level
,
This
->
mipmap_level
,
0
,
0
,
0
,
0
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
src_d
->
dwWidth
,
src_d
->
dwHeight
,
GL_RGBA
,
format
,
GL_UNSIGNED_BYTE
,
pixel_format
,
src_d
->
lpSurface
);
surface
==
NULL
?
src_d
->
lpSurface
:
surface
);
}
else
{
if
(
surface
)
HeapFree
(
GetProcessHeap
(),
0
,
surface
);
ERR
(
"Unhandled texture format (bad RGB count)
\n
"
);
}
}
else
{
ERR
(
"Unhandled texture format (neither RGB nor INDEX)
\n
"
);
}
}
glBindTexture
(
GL_TEXTURE_2D
,
current_texture
);
glBindTexture
(
GL_TEXTURE_2D
,
current_texture
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment