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
Package registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shin_Kinr
SRB2
Commits
086463bc
Commit
086463bc
authored
10 years ago
by
Alam Ed Arias
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'Furyhunter/sdl2' into sdl2
parents
b19a9077
93e00cc6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sdl2/i_video.c
+41
-50
41 additions, 50 deletions
src/sdl2/i_video.c
with
41 additions
and
50 deletions
src/sdl2/i_video.c
+
41
−
50
View file @
086463bc
...
@@ -132,6 +132,7 @@ static SDL_bool mousegrabok = SDL_TRUE;
...
@@ -132,6 +132,7 @@ static SDL_bool mousegrabok = SDL_TRUE;
#define HalfWarpMouse(x,y) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2))
#define HalfWarpMouse(x,y) SDL_WarpMouseInWindow(window, (Uint16)(x/2),(Uint16)(y/2))
static
SDL_bool
videoblitok
=
SDL_FALSE
;
static
SDL_bool
videoblitok
=
SDL_FALSE
;
static
SDL_bool
exposevideo
=
SDL_FALSE
;
static
SDL_bool
exposevideo
=
SDL_FALSE
;
static
SDL_bool
usesdl2soft
=
SDL_FALSE
;
// SDL2 vars
// SDL2 vars
SDL_Window
*
window
;
SDL_Window
*
window
;
...
@@ -170,10 +171,11 @@ static void Impl_SetWindowIcon(void);
...
@@ -170,10 +171,11 @@ static void Impl_SetWindowIcon(void);
static
void
SDLSetMode
(
INT32
width
,
INT32
height
,
SDL_bool
fullscreen
)
static
void
SDLSetMode
(
INT32
width
,
INT32
height
,
SDL_bool
fullscreen
)
{
{
static
SDL_bool
wasfullscreen
=
SDL_FALSE
;
static
SDL_bool
wasfullscreen
=
SDL_FALSE
;
int
rmask
;
Uint32
rmask
;
int
gmask
;
Uint32
gmask
;
int
bmask
;
Uint32
bmask
;
int
amask
;
Uint32
amask
;
int
bpp
=
16
;
int
sw_texture_format
=
SDL_PIXELFORMAT_ABGR8888
;
int
sw_texture_format
=
SDL_PIXELFORMAT_ABGR8888
;
realwidth
=
vid
.
width
;
realwidth
=
vid
.
width
;
...
@@ -181,7 +183,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
...
@@ -181,7 +183,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
if
(
window
)
if
(
window
)
{
{
if
(
fullscreen
&&
!
wasfullscreen
)
if
(
fullscreen
)
{
{
wasfullscreen
=
SDL_TRUE
;
wasfullscreen
=
SDL_TRUE
;
SDL_SetWindowFullscreen
(
window
,
SDL_WINDOW_FULLSCREEN_DESKTOP
);
SDL_SetWindowFullscreen
(
window
,
SDL_WINDOW_FULLSCREEN_DESKTOP
);
...
@@ -202,9 +204,14 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
...
@@ -202,9 +204,14 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
}
}
else
else
{
{
Impl_CreateWindow
(
fullscreen
?
SDL_TRUE
:
SDL_FALSE
);
Impl_CreateWindow
(
fullscreen
);
Impl_SetWindowIcon
();
Impl_SetWindowIcon
();
wasfullscreen
=
fullscreen
?
SDL_TRUE
:
SDL_FALSE
;
wasfullscreen
=
fullscreen
;
SDL_SetWindowSize
(
window
,
width
,
height
);
if
(
fullscreen
)
{
SDL_SetWindowFullscreen
(
window
,
SDL_WINDOW_FULLSCREEN_DESKTOP
);
}
}
}
if
(
rendermode
==
render_opengl
)
if
(
rendermode
==
render_opengl
)
...
@@ -213,7 +220,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
...
@@ -213,7 +220,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
SDL_GetWindowSize
(
window
,
&
sdlw
,
&
sdlh
);
SDL_GetWindowSize
(
window
,
&
sdlw
,
&
sdlh
);
// Logical fullscreen is not implemented yet for OpenGL, so...
// Logical fullscreen is not implemented yet for OpenGL, so...
// Special case handling
// Special case handling
if
(
USE_FULLSCREEN
&&
width
!=
sdlw
&&
height
!=
sdlh
)
if
(
fullscreen
&&
width
!=
sdlw
&&
height
!=
sdlh
)
{
{
VID_SetMode
(
VID_GetModeForSize
(
sdlw
,
sdlh
));
VID_SetMode
(
VID_GetModeForSize
(
sdlw
,
sdlh
));
return
;
return
;
...
@@ -223,8 +230,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
...
@@ -223,8 +230,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
if
(
rendermode
==
render_soft
)
if
(
rendermode
==
render_soft
)
{
{
SDL_RenderSetLogicalSize
(
renderer
,
width
,
height
);
SDL_RenderClear
(
renderer
);
SDL_RenderClear
(
renderer
);
SDL_RenderSetLogicalSize
(
renderer
,
width
,
height
);
// Set up Texture
// Set up Texture
realwidth
=
width
;
realwidth
=
width
;
realheight
=
height
;
realheight
=
height
;
...
@@ -232,11 +239,16 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
...
@@ -232,11 +239,16 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
{
{
SDL_DestroyTexture
(
texture
);
SDL_DestroyTexture
(
texture
);
}
}
#ifdef SDL_BIG_ENDIAN
sw_texture_format
=
SDL_PIXELFORMAT_RGBA8888
;
if
(
!
usesdl2soft
)
#else
{
sw_texture_format
=
SDL_PIXELFORMAT_ABGR8888
;
sw_texture_format
=
SDL_PIXELFORMAT_RGB565
;
#endif
}
else
{
sw_texture_format
=
SDL_PIXELFORMAT_RGBA8888
;
}
texture
=
SDL_CreateTexture
(
renderer
,
sw_texture_format
,
SDL_TEXTUREACCESS_STREAMING
,
width
,
height
);
texture
=
SDL_CreateTexture
(
renderer
,
sw_texture_format
,
SDL_TEXTUREACCESS_STREAMING
,
width
,
height
);
// Set up SW surface
// Set up SW surface
...
@@ -244,18 +256,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
...
@@ -244,18 +256,8 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
{
{
SDL_FreeSurface
(
vidSurface
);
SDL_FreeSurface
(
vidSurface
);
}
}
#ifdef SDL_BIG_ENDIAN
SDL_PixelFormatEnumToMasks
(
sw_texture_format
,
&
bpp
,
&
rmask
,
&
gmask
,
&
bmask
,
&
amask
);
rmask
=
0xFF000000
;
vidSurface
=
SDL_CreateRGBSurface
(
0
,
width
,
height
,
bpp
,
rmask
,
gmask
,
bmask
,
amask
);
gmask
=
0x00FF0000
;
bmask
=
0x0000FF00
;
amask
=
0x000000FF
;
#else // HEAD HEADS UP THE ASSIGNMENT ORDER IS FLIPPED, I WAS LAZY --Fury
amask
=
0xFF000000
;
bmask
=
0x00FF0000
;
gmask
=
0x0000FF00
;
rmask
=
0x000000FF
;
#endif
vidSurface
=
SDL_CreateRGBSurface
(
0
,
width
,
height
,
32
,
rmask
,
gmask
,
bmask
,
amask
);
}
}
}
}
...
@@ -1372,36 +1374,18 @@ void I_FinishUpdate(void)
...
@@ -1372,36 +1374,18 @@ void I_FinishUpdate(void)
rect
.
w
=
vid
.
width
;
rect
.
w
=
vid
.
width
;
rect
.
h
=
vid
.
height
;
rect
.
h
=
vid
.
height
;
if
(
vidSurface
->
h
>
vid
.
height
)
rect
.
y
=
(
Sint16
)((
vidSurface
->
h
-
vid
.
height
)
/
2
);
if
(
!
bufSurface
)
//Double-Check
if
(
!
bufSurface
)
//Double-Check
{
{
Impl_VideoSetupSDLBuffer
();
Impl_VideoSetupSDLBuffer
();
}
}
if
(
bufSurface
)
//Alam: New Way to send video data
if
(
bufSurface
)
{
{
void
*
pixels
;
int
pitch
;
SDL_BlitSurface
(
bufSurface
,
NULL
,
vidSurface
,
&
rect
);
SDL_BlitSurface
(
bufSurface
,
NULL
,
vidSurface
,
&
rect
);
// Fury --
streaming textu
res
are bad on
UpdateTexture
// Fury --
the
re
'
s
no way around
UpdateTexture
, the GL backend uses it anyway
SDL_LockSurface
(
vidSurface
);
SDL_LockSurface
(
vidSurface
);
SDL_LockTexture
(
texture
,
&
rect
,
&
pixels
,
&
pitch
);
SDL_UpdateTexture
(
texture
,
&
rect
,
vidSurface
->
pixels
,
vidSurface
->
pitch
);
if
(
pitch
==
vidSurface
->
pitch
)
{
M_Memcpy
(
pixels
,
vidSurface
->
pixels
,
(
pitch
*
vid
.
height
));
}
else
{
SDL_UnlockTexture
(
texture
);
SDL_UnlockSurface
(
vidSurface
);
I_Error
(
"The intermediate buffer and final texture types are not the same.
\n
"
);
}
SDL_UnlockTexture
(
texture
);
SDL_UnlockSurface
(
vidSurface
);
SDL_UnlockSurface
(
vidSurface
);
}
}
// Blit buffer to texture
SDL_RenderCopy
(
renderer
,
texture
,
NULL
,
NULL
);
SDL_RenderCopy
(
renderer
,
texture
,
NULL
,
NULL
);
SDL_RenderPresent
(
renderer
);
SDL_RenderPresent
(
renderer
);
}
}
...
@@ -1705,7 +1689,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
...
@@ -1705,7 +1689,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
realwidth
,
realheight
,
flags
);
realwidth
,
realheight
,
flags
);
if
(
window
!=
NULL
)
if
(
window
!=
NULL
)
{
{
renderer
=
SDL_CreateRenderer
(
window
,
-
1
,
0
);
renderer
=
SDL_CreateRenderer
(
window
,
-
1
,
(
usesdl2soft
?
SDL_RENDERER_SOFTWARE
:
0
)
|
(
cv_vidwait
.
value
&&
!
usesdl2soft
?
SDL_RENDERER_PRESENTVSYNC
:
0
)
);
if
(
renderer
!=
NULL
)
if
(
renderer
!=
NULL
)
{
{
SDL_RenderSetLogicalSize
(
renderer
,
BASEVIDWIDTH
,
BASEVIDHEIGHT
);
SDL_RenderSetLogicalSize
(
renderer
,
BASEVIDWIDTH
,
BASEVIDHEIGHT
);
...
@@ -1831,7 +1815,13 @@ void I_StartupGraphics(void)
...
@@ -1831,7 +1815,13 @@ void I_StartupGraphics(void)
framebuffer
=
SDL_TRUE
;
framebuffer
=
SDL_TRUE
;
}
}
if
(
M_CheckParm
(
"-software"
))
if
(
M_CheckParm
(
"-software"
))
{
rendermode
=
render_soft
;
rendermode
=
render_soft
;
}
if
(
M_CheckParm
(
"-softblit"
))
{
usesdl2soft
=
SDL_TRUE
;
}
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2);
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2);
SDLESSet
();
SDLESSet
();
VID_Command_ModeList_f
();
VID_Command_ModeList_f
();
...
@@ -1878,8 +1868,9 @@ void I_StartupGraphics(void)
...
@@ -1878,8 +1868,9 @@ void I_StartupGraphics(void)
// SDL_GL_LoadLibrary to work well on Windows
// SDL_GL_LoadLibrary to work well on Windows
// Create window
// Create window
Impl_CreateWindow
(
USE_FULLSCREEN
);
//Impl_CreateWindow(USE_FULLSCREEN);
Impl_SetWindowName
(
"SRB2"
);
//Impl_SetWindowName("SRB2");
VID_SetMode
(
VID_GetModeForSize
(
BASEVIDWIDTH
,
BASEVIDHEIGHT
));
vid
.
buffer
=
NULL
;
// For software mode
vid
.
buffer
=
NULL
;
// For software mode
vid
.
width
=
BASEVIDWIDTH
;
// Default size for startup
vid
.
width
=
BASEVIDWIDTH
;
// Default size for startup
...
...
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