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
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julius Enriquez
SRB2
Commits
a1553c46
Commit
a1553c46
authored
4 years ago
by
Lactozilla
Browse files
Options
Downloads
Patches
Plain Diff
Update r_opengl.c
parent
75ebdda3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/hardware/r_opengl/r_opengl.c
+22
-53
22 additions, 53 deletions
src/hardware/r_opengl/r_opengl.c
with
22 additions
and
53 deletions
src/hardware/r_opengl/r_opengl.c
+
22
−
53
View file @
a1553c46
...
...
@@ -62,6 +62,9 @@ static FBITFIELD CurrentPolyFlags;
static
FTextureInfo
*
TexCacheTail
=
NULL
;
static
FTextureInfo
*
TexCacheHead
=
NULL
;
static
RGBA_t
*
textureBuffer
=
NULL
;
static
size_t
textureBufferSize
=
0
;
RGBA_t
myPaletteData
[
256
];
GLint
screen_width
=
0
;
// used by Draw2DLine()
GLint
screen_height
=
0
;
...
...
@@ -202,32 +205,6 @@ static void GL_MSG_Error(const char *format, ...)
#endif
}
// ----------------------+
// GetTextureFormatName : Returns the corresponding texture format string from the texture format enumeration.
// ----------------------+
static
const
char
*
GetTextureFormatName
(
INT32
format
)
{
static
char
num
[
12
];
switch
(
format
)
{
case
GL_TEXFMT_P_8
:
return
"GL_TEXFMT_P_8"
;
case
GL_TEXFMT_AP_88
:
return
"GL_TEXFMT_AP_88"
;
case
GL_TEXFMT_RGBA
:
return
"GL_TEXFMT_RGBA"
;
case
GL_TEXFMT_ALPHA_8
:
return
"GL_TEXFMT_ALPHA_8"
;
case
GL_TEXFMT_INTENSITY_8
:
return
"GL_TEXFMT_INTENSITY_8"
;
case
GL_TEXFMT_ALPHA_INTENSITY_88
:
return
"GL_TEXFMT_ALPHA_INTENSITY_88"
;
default:
break
;
}
// If the texture format is not known (due to it being invalid),
// return a string containing the format index instead.
format
=
INT32_MIN
;
snprintf
(
num
,
sizeof
(
num
),
"%d"
,
format
);
return
num
;
}
#ifdef STATIC_OPENGL
/* 1.0 functions */
/* Miscellaneous */
...
...
@@ -1366,6 +1343,10 @@ void Flush(void)
TexCacheTail
=
TexCacheHead
=
NULL
;
//Hurdler: well, TexCacheHead is already NULL
tex_downloaded
=
0
;
free
(
textureBuffer
);
textureBuffer
=
NULL
;
textureBufferSize
=
0
;
}
...
...
@@ -1758,28 +1739,16 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags)
CurrentPolyFlags
=
PolyFlags
;
}
// -------------------+
// AllocTextureBuffer : Allocates memory for converting a non-RGBA texture into an RGBA texture.
// -------------------+
static
RGBA_t
*
AllocTextureBuffer
(
GLMipmap_t
*
pTexInfo
)
static
void
AllocTextureBuffer
(
GLMipmap_t
*
pTexInfo
)
{
size_t
len
=
(
pTexInfo
->
width
*
pTexInfo
->
height
);
RGBA_t
*
tex
=
calloc
(
len
,
sizeof
(
RGBA_t
));
if
(
tex
==
NULL
)
I_Error
(
"AllocTextureBuffer: out of memory allocating %s bytes for texture %d, format %s"
,
sizeu1
(
len
*
sizeof
(
RGBA_t
)),
pTexInfo
->
downloaded
,
GetTextureFormatName
(
pTexInfo
->
format
));
return
tex
;
}
// ------------------+
// FreeTextureBuffer : Frees memory allocated by AllocTextureBuffer.
// ------------------+
static
void
FreeTextureBuffer
(
RGBA_t
*
tex
)
{
if
(
tex
)
free
(
tex
);
size_t
size
=
pTexInfo
->
width
*
pTexInfo
->
height
;
if
(
size
>
textureBufferSize
)
{
textureBuffer
=
realloc
(
textureBuffer
,
size
*
sizeof
(
RGBA_t
));
if
(
textureBuffer
==
NULL
)
I_Error
(
"AllocTextureBuffer: out of memory allocating %s bytes"
,
sizeu1
(
size
*
sizeof
(
RGBA_t
)));
textureBufferSize
=
size
;
}
}
// -----------------+
...
...
@@ -1810,7 +1779,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
if
((
pTexInfo
->
format
==
GL_TEXFMT_P_8
)
||
(
pTexInfo
->
format
==
GL_TEXFMT_AP_88
))
{
ptex
=
tex
=
AllocTextureBuffer
(
pTexInfo
);
AllocTextureBuffer
(
pTexInfo
);
ptex
=
tex
=
textureBuffer
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
...
...
@@ -1851,7 +1821,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
else
if
(
pTexInfo
->
format
==
GL_TEXFMT_ALPHA_INTENSITY_88
)
{
ptex
=
tex
=
AllocTextureBuffer
(
pTexInfo
);
AllocTextureBuffer
(
pTexInfo
);
ptex
=
tex
=
textureBuffer
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
...
...
@@ -1868,7 +1839,8 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
else
if
(
pTexInfo
->
format
==
GL_TEXFMT_ALPHA_8
)
// Used for fade masks
{
ptex
=
tex
=
AllocTextureBuffer
(
pTexInfo
);
AllocTextureBuffer
(
pTexInfo
);
ptex
=
tex
=
textureBuffer
;
for
(
j
=
0
;
j
<
h
;
j
++
)
{
...
...
@@ -1963,9 +1935,6 @@ EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *pTexInfo)
}
}
// Free the texture buffer
FreeTextureBuffer
(
tex
);
if
(
pTexInfo
->
flags
&
TF_WRAPX
)
pglTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_REPEAT
);
else
...
...
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