Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
6950191f
Commit
6950191f
authored
Feb 03, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create the video texture based on the available texture formats, not the backbuffer format.
parent
fe2b0d97
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
55 deletions
+14
-55
SDL_compat.c
src/SDL_compat.c
+14
-55
No files found.
src/SDL_compat.c
View file @
6950191f
...
@@ -470,9 +470,10 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
...
@@ -470,9 +470,10 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
int
window_x
=
SDL_WINDOWPOS_UNDEFINED
;
int
window_x
=
SDL_WINDOWPOS_UNDEFINED
;
int
window_y
=
SDL_WINDOWPOS_UNDEFINED
;
int
window_y
=
SDL_WINDOWPOS_UNDEFINED
;
Uint32
window_flags
;
Uint32
window_flags
;
Uint32
desktop_format
;
Uint32
desired_format
;
Uint32
surface_flags
;
Uint32
surface_flags
;
Uint32
i
;
SDL_RendererInfo
info
;
Uint32
desired_format
;
if
(
!
SDL_GetVideoDevice
())
{
if
(
!
SDL_GetVideoDevice
())
{
if
(
SDL_Init
(
SDL_INIT_VIDEO
|
SDL_INIT_NOPARACHUTE
)
<
0
)
{
if
(
SDL_Init
(
SDL_INIT_VIDEO
|
SDL_INIT_NOPARACHUTE
)
<
0
)
{
...
@@ -490,6 +491,9 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
...
@@ -490,6 +491,9 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
if
(
height
==
0
)
{
if
(
height
==
0
)
{
height
=
desktop_mode
.
h
;
height
=
desktop_mode
.
h
;
}
}
if
(
bpp
==
0
)
{
bpp
=
SDL_BITSPERPIXEL
(
desktop_mode
.
format
);
}
/* See if we can simply resize the existing window and surface */
/* See if we can simply resize the existing window and surface */
if
(
SDL_ResizeVideoMode
(
width
,
height
,
bpp
,
flags
)
==
0
)
{
if
(
SDL_ResizeVideoMode
(
width
,
height
,
bpp
,
flags
)
==
0
)
{
...
@@ -559,53 +563,6 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
...
@@ -559,53 +563,6 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
surface_flags
|=
SDL_NOFRAME
;
surface_flags
|=
SDL_NOFRAME
;
}
}
/* Set up the desired display mode */
desktop_format
=
desktop_mode
.
format
;
if
(
desktop_format
&&
((
flags
&
SDL_ANYFORMAT
)
||
(
bpp
==
SDL_BITSPERPIXEL
(
desktop_format
))))
{
desired_format
=
desktop_format
;
}
else
{
switch
(
bpp
)
{
case
0
:
if
(
desktop_format
)
{
desired_format
=
desktop_format
;
}
else
{
desired_format
=
SDL_PIXELFORMAT_RGB888
;
}
bpp
=
SDL_BITSPERPIXEL
(
desired_format
);
break
;
case
8
:
desired_format
=
SDL_PIXELFORMAT_INDEX8
;
break
;
case
15
:
desired_format
=
SDL_PIXELFORMAT_RGB555
;
break
;
case
16
:
desired_format
=
SDL_PIXELFORMAT_RGB565
;
break
;
case
24
:
desired_format
=
SDL_PIXELFORMAT_RGB24
;
break
;
case
32
:
desired_format
=
SDL_PIXELFORMAT_RGB888
;
break
;
default:
SDL_SetError
(
"Unsupported bpp in SDL_SetVideoMode()"
);
return
NULL
;
}
}
/* Set up the desired display mode */
if
(
flags
&
SDL_FULLSCREEN
)
{
SDL_DisplayMode
mode
;
SDL_zero
(
mode
);
mode
.
format
=
desired_format
;
if
(
SDL_SetWindowDisplayMode
(
SDL_VideoWindow
,
&
mode
)
<
0
)
{
return
NULL
;
}
}
/* If we're in OpenGL mode, just create a stub surface and we're done! */
/* If we're in OpenGL mode, just create a stub surface and we're done! */
if
(
flags
&
SDL_OPENGL
)
{
if
(
flags
&
SDL_OPENGL
)
{
SDL_VideoContext
=
SDL_GL_CreateContext
(
SDL_VideoWindow
);
SDL_VideoContext
=
SDL_GL_CreateContext
(
SDL_VideoWindow
);
...
@@ -632,15 +589,17 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
...
@@ -632,15 +589,17 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
}
}
/* Create a texture for the screen surface */
/* Create a texture for the screen surface */
SDL_GetRendererInfo
(
SDL_VideoRenderer
,
&
info
);
desired_format
=
info
.
texture_formats
[
0
];
for
(
i
=
0
;
i
<
info
.
num_texture_formats
;
++
i
)
{
if
(
!
SDL_ISPIXELFORMAT_ALPHA
(
info
.
texture_formats
[
i
]))
{
desired_format
=
info
.
texture_formats
[
i
];
break
;
}
}
SDL_VideoTexture
=
SDL_CreateTexture
(
SDL_VideoRenderer
,
desired_format
,
SDL_VideoTexture
=
SDL_CreateTexture
(
SDL_VideoRenderer
,
desired_format
,
SDL_TEXTUREACCESS_STREAMING
,
SDL_TEXTUREACCESS_STREAMING
,
width
,
height
);
width
,
height
);
if
(
!
SDL_VideoTexture
)
{
SDL_VideoTexture
=
SDL_CreateTexture
(
SDL_VideoRenderer
,
desktop_format
,
SDL_TEXTUREACCESS_STREAMING
,
width
,
height
);
}
if
(
!
SDL_VideoTexture
)
{
if
(
!
SDL_VideoTexture
)
{
return
NULL
;
return
NULL
;
}
}
...
...
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