Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STJr
SRB2
Commits
06d6e2e0
Commit
06d6e2e0
authored
5 years ago
by
Lactozilla
Browse files
Options
Downloads
Patches
Plain Diff
Move location of R_GetTextureFlat
parent
762ce146
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!675
PNG conversion refactoring
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/r_plane.c
+0
-101
0 additions, 101 deletions
src/r_plane.c
src/r_textures.c
+101
-0
101 additions, 0 deletions
src/r_textures.c
src/r_textures.h
+1
-0
1 addition, 0 deletions
src/r_textures.h
with
102 additions
and
101 deletions
src/r_plane.c
+
0
−
101
View file @
06d6e2e0
...
...
@@ -765,107 +765,6 @@ void R_CheckFlatLength(size_t size)
}
}
//
// R_GetTextureFlat
//
// Convert a texture or patch to a flat.
//
static
UINT8
*
R_GetTextureFlat
(
levelflat_t
*
levelflat
,
boolean
leveltexture
,
boolean
ispng
)
{
UINT8
*
flat
;
textureflat_t
*
texflat
=
&
texflats
[
levelflat
->
u
.
texture
.
num
];
patch_t
*
patch
=
NULL
;
boolean
texturechanged
=
(
leveltexture
?
(
levelflat
->
u
.
texture
.
num
!=
levelflat
->
u
.
texture
.
lastnum
)
:
false
);
(
void
)
ispng
;
// Check if the texture changed.
if
(
leveltexture
&&
(
!
texturechanged
))
{
if
(
texflat
!=
NULL
&&
texflat
->
flat
)
{
flat
=
texflat
->
flat
;
ds_flatwidth
=
texflat
->
width
;
ds_flatheight
=
texflat
->
height
;
texturechanged
=
false
;
}
else
texturechanged
=
true
;
}
// If the texture changed, or the patch doesn't exist, convert either of them to a flat.
if
(
levelflat
->
flatpatch
==
NULL
||
texturechanged
)
{
// Level texture
if
(
leveltexture
)
{
UINT8
*
converted
;
size_t
size
;
texture_t
*
texture
=
textures
[
levelflat
->
u
.
texture
.
num
];
texflat
->
width
=
ds_flatwidth
=
texture
->
width
;
texflat
->
height
=
ds_flatheight
=
texture
->
height
;
size
=
(
texflat
->
width
*
texflat
->
height
);
texflat
->
flat
=
Z_Malloc
(
size
,
PU_LEVEL
,
NULL
);
converted
=
(
UINT8
*
)
Picture_TextureToFlat
(
levelflat
->
u
.
texture
.
num
);
M_Memcpy
(
texflat
->
flat
,
converted
,
size
);
Z_Free
(
converted
);
flat
=
texflat
->
flat
;
levelflat
->
flatpatch
=
flat
;
levelflat
->
width
=
ds_flatwidth
;
levelflat
->
height
=
ds_flatheight
;
}
// Patch (never happens yet)
else
{
patch
=
(
patch_t
*
)
ds_source
;
#ifndef NO_PNG_LUMPS
if
(
ispng
)
{
INT32
pngwidth
,
pngheight
;
levelflat
->
flatpatch
=
Picture_PNGConvert
(
ds_source
,
PICFMT_FLAT
,
&
pngwidth
,
&
pngheight
,
NULL
,
NULL
,
W_LumpLength
(
levelflat
->
u
.
flat
.
lumpnum
),
NULL
,
0
);
levelflat
->
topoffset
=
levelflat
->
leftoffset
=
0
;
levelflat
->
width
=
(
UINT16
)
pngwidth
;
levelflat
->
height
=
(
UINT16
)
pngheight
;
ds_flatwidth
=
levelflat
->
width
;
ds_flatheight
=
levelflat
->
height
;
}
else
#endif
{
UINT8
*
converted
;
size_t
size
;
levelflat
->
width
=
ds_flatwidth
=
SHORT
(
patch
->
width
);
levelflat
->
height
=
ds_flatheight
=
SHORT
(
patch
->
height
);
levelflat
->
topoffset
=
patch
->
topoffset
*
FRACUNIT
;
levelflat
->
leftoffset
=
patch
->
leftoffset
*
FRACUNIT
;
levelflat
->
flatpatch
=
Z_Malloc
(
levelflat
->
width
*
levelflat
->
height
,
PU_LEVEL
,
NULL
);
converted
=
Picture_FlatConvert
(
PICFMT_PATCH
,
patch
,
PICFMT_FLAT
,
0
,
&
size
,
levelflat
->
width
,
levelflat
->
height
,
patch
->
topoffset
,
patch
->
leftoffset
,
0
);
M_Memcpy
(
levelflat
->
flatpatch
,
converted
,
size
);
Z_Free
(
converted
);
}
flat
=
levelflat
->
flatpatch
;
}
}
else
{
flat
=
levelflat
->
flatpatch
;
ds_flatwidth
=
levelflat
->
width
;
ds_flatheight
=
levelflat
->
height
;
}
xoffs
+=
levelflat
->
leftoffset
;
yoffs
+=
levelflat
->
topoffset
;
levelflat
->
u
.
texture
.
lastnum
=
levelflat
->
u
.
texture
.
num
;
return
flat
;
}
#ifdef ESLOPE
static
void
R_SlopeVectors
(
visplane_t
*
pl
,
INT32
i
,
float
fudge
)
{
...
...
This diff is collapsed.
Click to expand it.
src/r_textures.c
+
101
−
0
View file @
06d6e2e0
...
...
@@ -502,6 +502,107 @@ UINT8 *R_GetFlat(lumpnum_t flatlumpnum)
return
W_CacheLumpNum
(
flatlumpnum
,
PU_CACHE
);
}
//
// R_GetTextureFlat
//
// Convert a texture or patch to a flat.
//
UINT8
*
R_GetTextureFlat
(
levelflat_t
*
levelflat
,
boolean
leveltexture
,
boolean
ispng
)
{
UINT8
*
flat
;
textureflat_t
*
texflat
=
&
texflats
[
levelflat
->
u
.
texture
.
num
];
patch_t
*
patch
=
NULL
;
boolean
texturechanged
=
(
leveltexture
?
(
levelflat
->
u
.
texture
.
num
!=
levelflat
->
u
.
texture
.
lastnum
)
:
false
);
(
void
)
ispng
;
// Check if the texture changed.
if
(
leveltexture
&&
(
!
texturechanged
))
{
if
(
texflat
!=
NULL
&&
texflat
->
flat
)
{
flat
=
texflat
->
flat
;
ds_flatwidth
=
texflat
->
width
;
ds_flatheight
=
texflat
->
height
;
texturechanged
=
false
;
}
else
texturechanged
=
true
;
}
// If the texture changed, or the patch doesn't exist, convert either of them to a flat.
if
(
levelflat
->
flatpatch
==
NULL
||
texturechanged
)
{
// Level texture
if
(
leveltexture
)
{
UINT8
*
converted
;
size_t
size
;
texture_t
*
texture
=
textures
[
levelflat
->
u
.
texture
.
num
];
texflat
->
width
=
ds_flatwidth
=
texture
->
width
;
texflat
->
height
=
ds_flatheight
=
texture
->
height
;
size
=
(
texflat
->
width
*
texflat
->
height
);
texflat
->
flat
=
Z_Malloc
(
size
,
PU_LEVEL
,
NULL
);
converted
=
(
UINT8
*
)
Picture_TextureToFlat
(
levelflat
->
u
.
texture
.
num
);
M_Memcpy
(
texflat
->
flat
,
converted
,
size
);
Z_Free
(
converted
);
flat
=
texflat
->
flat
;
levelflat
->
flatpatch
=
flat
;
levelflat
->
width
=
ds_flatwidth
;
levelflat
->
height
=
ds_flatheight
;
}
// Patch (never happens yet)
else
{
patch
=
(
patch_t
*
)
ds_source
;
#ifndef NO_PNG_LUMPS
if
(
ispng
)
{
INT32
pngwidth
,
pngheight
;
levelflat
->
flatpatch
=
Picture_PNGConvert
(
ds_source
,
PICFMT_FLAT
,
&
pngwidth
,
&
pngheight
,
NULL
,
NULL
,
W_LumpLength
(
levelflat
->
u
.
flat
.
lumpnum
),
NULL
,
0
);
levelflat
->
topoffset
=
levelflat
->
leftoffset
=
0
;
levelflat
->
width
=
(
UINT16
)
pngwidth
;
levelflat
->
height
=
(
UINT16
)
pngheight
;
ds_flatwidth
=
levelflat
->
width
;
ds_flatheight
=
levelflat
->
height
;
}
else
#endif
{
UINT8
*
converted
;
size_t
size
;
levelflat
->
width
=
ds_flatwidth
=
SHORT
(
patch
->
width
);
levelflat
->
height
=
ds_flatheight
=
SHORT
(
patch
->
height
);
levelflat
->
topoffset
=
patch
->
topoffset
*
FRACUNIT
;
levelflat
->
leftoffset
=
patch
->
leftoffset
*
FRACUNIT
;
levelflat
->
flatpatch
=
Z_Malloc
(
levelflat
->
width
*
levelflat
->
height
,
PU_LEVEL
,
NULL
);
converted
=
Picture_FlatConvert
(
PICFMT_PATCH
,
patch
,
PICFMT_FLAT
,
0
,
&
size
,
levelflat
->
width
,
levelflat
->
height
,
patch
->
topoffset
,
patch
->
leftoffset
,
0
);
M_Memcpy
(
levelflat
->
flatpatch
,
converted
,
size
);
Z_Free
(
converted
);
}
flat
=
levelflat
->
flatpatch
;
}
}
else
{
flat
=
levelflat
->
flatpatch
;
ds_flatwidth
=
levelflat
->
width
;
ds_flatheight
=
levelflat
->
height
;
}
//xoffs += levelflat->leftoffset;
//yoffs += levelflat->topoffset;
levelflat
->
u
.
texture
.
lastnum
=
levelflat
->
u
.
texture
.
num
;
return
flat
;
}
//
// Empty the texture cache (used for load wad at runtime)
//
...
...
This diff is collapsed.
Click to expand it.
src/r_textures.h
+
1
−
0
View file @
06d6e2e0
...
...
@@ -94,6 +94,7 @@ void R_ClearTextureNumCache(boolean btell);
// Retrieve texture data.
UINT8
*
R_GetColumn
(
fixed_t
tex
,
INT32
col
);
UINT8
*
R_GetFlat
(
lumpnum_t
flatnum
);
UINT8
*
R_GetTextureFlat
(
levelflat_t
*
levelflat
,
boolean
leveltexture
,
boolean
ispng
);
// Returns the texture number for the texture name.
INT32
R_TextureNumForName
(
const
char
*
name
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment