Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
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
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Lisa Greene
Tales of MajEyal
Commits
8721a80e
Commit
8721a80e
authored
11 years ago
by
Steven Noonan
Browse files
Options
Downloads
Patches
Plain Diff
unbreak texture and text rendering on big endian architectures
Signed-off-by:
Steven Noonan
<
steven@uplinklabs.net
>
parent
abe424d6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core_lua.c
+61
-8
61 additions, 8 deletions
src/core_lua.c
with
61 additions
and
8 deletions
src/core_lua.c
+
61
−
8
View file @
8721a80e
...
...
@@ -64,6 +64,53 @@ int SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
return
0
;
}
SDL_Surface
*
SDL_DisplayFormatAlpha
(
SDL_Surface
*
surface
)
{
SDL_Surface
*
image
;
SDL_Rect
area
;
Uint8
saved_alpha
;
SDL_BlendMode
saved_mode
;
image
=
SDL_CreateRGBSurface
(
SDL_SWSURFACE
,
surface
->
w
,
surface
->
h
,
32
,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
/* OpenGL RGBA masks */
0x000000FF
,
0x0000FF00
,
0x00FF0000
,
0xFF000000
#else
0xFF000000
,
0x00FF0000
,
0x0000FF00
,
0x000000FF
#endif
);
if
(
image
==
NULL
)
{
return
0
;
}
/* Save the alpha blending attributes */
SDL_GetSurfaceAlphaMod
(
surface
,
&
saved_alpha
);
SDL_SetSurfaceAlphaMod
(
surface
,
0xFF
);
SDL_GetSurfaceBlendMode
(
surface
,
&
saved_mode
);
SDL_SetSurfaceBlendMode
(
surface
,
SDL_BLENDMODE_NONE
);
/* Copy the surface into the GL texture image */
area
.
x
=
0
;
area
.
y
=
0
;
area
.
w
=
surface
->
w
;
area
.
h
=
surface
->
h
;
SDL_BlitSurface
(
surface
,
&
area
,
image
,
&
area
);
/* Restore the alpha blending attributes */
SDL_SetSurfaceAlphaMod
(
surface
,
saved_alpha
);
SDL_SetSurfaceBlendMode
(
surface
,
saved_mode
);
return
image
;
}
typedef
struct
SDL_VideoInfo
{
Uint32
hw_available
:
1
;
...
...
@@ -185,15 +232,23 @@ static GLenum sdl_gl_texture_format(SDL_Surface *s) {
// get the number of channels in the SDL surface
GLint
nOfColors
=
s
->
format
->
BytesPerPixel
;
GLenum
texture_format
;
if
(
nOfColors
==
4
)
// contains an alpha channel
if
(
nOfColors
==
4
)
// contains an alpha channel
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
if
(
s
->
format
->
Rmask
==
0xff000000
)
#else
if
(
s
->
format
->
Rmask
==
0x000000ff
)
#endif
texture_format
=
GL_RGBA
;
else
texture_format
=
GL_BGRA
;
}
else
if
(
nOfColors
==
3
)
// no alpha channel
}
else
if
(
nOfColors
==
3
)
// no alpha channel
{
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
if
(
s
->
format
->
Rmask
==
0x00ff0000
)
#else
if
(
s
->
format
->
Rmask
==
0x000000ff
)
#endif
texture_format
=
GL_RGB
;
else
texture_format
=
GL_BGR
;
...
...
@@ -651,9 +706,8 @@ static int sdl_surface_drawstring_newsurface(lua_State *L)
{
SDL_Surface
**
s
=
(
SDL_Surface
**
)
lua_newuserdata
(
L
,
sizeof
(
SDL_Surface
*
));
auxiliar_setclass
(
L
,
"sdl{surface}"
,
-
1
);
// *s = SDL_DisplayFormatAlpha(txt);
// SDL_FreeSurface(txt);
*
s
=
txt
;
*
s
=
SDL_DisplayFormatAlpha
(
txt
);
SDL_FreeSurface
(
txt
);
return
1
;
}
...
...
@@ -677,9 +731,8 @@ static int sdl_surface_drawstring_newsurface_aa(lua_State *L)
{
SDL_Surface
**
s
=
(
SDL_Surface
**
)
lua_newuserdata
(
L
,
sizeof
(
SDL_Surface
*
));
auxiliar_setclass
(
L
,
"sdl{surface}"
,
-
1
);
// *s = SDL_DisplayFormatAlpha(txt);
// SDL_FreeSurface(txt);
*
s
=
txt
;
*
s
=
SDL_DisplayFormatAlpha
(
txt
);
SDL_FreeSurface
(
txt
);
return
1
;
}
...
...
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