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
1606a45b
Commit
1606a45b
authored
8 years ago
by
Monster Iestyn
Browse files
Options
Downloads
Patches
Plain Diff
Some cleanup/reorganisation in SDLSetMode and Impl_CreateWindow
parent
20854616
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!138
SDL2 i_video.c code cleanup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sdl/i_video.c
+37
-26
37 additions, 26 deletions
src/sdl/i_video.c
with
37 additions
and
26 deletions
src/sdl/i_video.c
+
37
−
26
View file @
1606a45b
...
@@ -189,14 +189,14 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
...
@@ -189,14 +189,14 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen)
wasfullscreen
=
SDL_TRUE
;
wasfullscreen
=
SDL_TRUE
;
SDL_SetWindowFullscreen
(
window
,
SDL_WINDOW_FULLSCREEN_DESKTOP
);
SDL_SetWindowFullscreen
(
window
,
SDL_WINDOW_FULLSCREEN_DESKTOP
);
}
}
else
if
(
!
fullscreen
&&
wasfullscreen
)
else
if
(
wasfullscreen
)
{
{
wasfullscreen
=
SDL_FALSE
;
wasfullscreen
=
SDL_FALSE
;
SDL_SetWindowFullscreen
(
window
,
0
);
SDL_SetWindowFullscreen
(
window
,
0
);
SDL_SetWindowSize
(
window
,
width
,
height
);
SDL_SetWindowSize
(
window
,
width
,
height
);
SDL_SetWindowPosition
(
window
,
SDL_WINDOWPOS_CENTERED_DISPLAY
(
1
),
SDL_WINDOWPOS_CENTERED_DISPLAY
(
1
));
SDL_SetWindowPosition
(
window
,
SDL_WINDOWPOS_CENTERED_DISPLAY
(
1
),
SDL_WINDOWPOS_CENTERED_DISPLAY
(
1
));
}
}
else
if
(
!
wasfullscreen
)
else
{
{
// Reposition window only in windowed mode
// Reposition window only in windowed mode
SDL_SetWindowSize
(
window
,
width
,
height
);
SDL_SetWindowSize
(
window
,
width
,
height
);
...
@@ -1550,6 +1550,12 @@ INT32 VID_SetMode(INT32 modeNum)
...
@@ -1550,6 +1550,12 @@ INT32 VID_SetMode(INT32 modeNum)
static
SDL_bool
Impl_CreateWindow
(
SDL_bool
fullscreen
)
static
SDL_bool
Impl_CreateWindow
(
SDL_bool
fullscreen
)
{
{
int
flags
=
0
;
int
flags
=
0
;
if
(
rendermode
==
render_none
)
// dedicated
{
return
SDL_TRUE
;
// Monster Iestyn -- not sure if it really matters what we return here tbh
}
if
(
window
!=
NULL
)
if
(
window
!=
NULL
)
{
{
return
SDL_FALSE
;
return
SDL_FALSE
;
...
@@ -1568,38 +1574,43 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
...
@@ -1568,38 +1574,43 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
#ifdef HWRENDER
#ifdef HWRENDER
if
(
rendermode
==
render_opengl
)
if
(
rendermode
==
render_opengl
)
{
{
window
=
SDL_CreateWindow
(
"SRB2 "
VERSIONSTRING
,
SDL_WINDOWPOS_CENTERED
,
SDL_WINDOWPOS_CENTERED
,
flags
|=
SDL_WINDOW_OPENGL
;
realwidth
,
realheight
,
flags
|
SDL_WINDOW_OPENGL
);
}
if
(
window
!=
NULL
)
#endif
// Create a window
window
=
SDL_CreateWindow
(
"SRB2 "
VERSIONSTRING
,
SDL_WINDOWPOS_CENTERED
,
SDL_WINDOWPOS_CENTERED
,
realwidth
,
realheight
,
flags
);
if
(
window
==
NULL
)
{
CONS_Printf
(
M_GetText
(
"Couldn't create window: %s
\n
"
),
SDL_GetError
());
return
SDL_FALSE
;
}
// Renderer-specific stuff
#ifdef HWRENDER
if
(
rendermode
==
render_opengl
)
{
sdlglcontext
=
SDL_GL_CreateContext
(
window
);
if
(
sdlglcontext
==
NULL
)
{
{
sdlglcontext
=
SDL_GL_CreateContext
(
window
);
SDL_DestroyWindow
(
window
);
if
(
sdlglcontext
==
NULL
)
I_Error
(
"Failed to create a GL context: %s
\n
"
,
SDL_GetError
());
{
SDL_DestroyWindow
(
window
);
I_Error
(
"Failed to create a GL context: %s
\n
"
,
SDL_GetError
());
}
else
{
SDL_GL_MakeCurrent
(
window
,
sdlglcontext
);
}
}
}
else
return
SDL_FALSE
;
SDL_GL_MakeCurrent
(
window
,
sdlglcontext
)
;
}
}
else
#endif
#endif
if
(
rendermode
==
render_soft
)
if
(
rendermode
==
render_soft
)
{
{
window
=
SDL_CreateWindow
(
"SRB2 "
VERSIONSTRING
,
SDL_WINDOWPOS_CENTERED
,
SDL_WINDOWPOS_CENTERED
,
renderer
=
SDL_CreateRenderer
(
window
,
-
1
,
(
usesdl2soft
?
SDL_RENDERER_SOFTWARE
:
0
)
|
(
cv_vidwait
.
value
&&
!
usesdl2soft
?
SDL_RENDERER_PRESENTVSYNC
:
0
));
realwidth
,
realheight
,
flags
);
if
(
renderer
==
NULL
)
if
(
window
!=
NULL
)
{
{
renderer
=
SDL_CreateRenderer
(
window
,
-
1
,
(
usesdl2soft
?
SDL_RENDERER_SOFTWARE
:
0
)
|
(
cv_vidwait
.
value
&&
!
usesdl2soft
?
SDL_RENDERER_PRESENTVSYNC
:
0
));
CONS_Printf
(
M_GetText
(
"Couldn't create rendering context: %s
\n
"
),
SDL_GetError
());
if
(
renderer
!=
NULL
)
return
SDL_FALSE
;
{
SDL_RenderSetLogicalSize
(
renderer
,
BASEVIDWIDTH
,
BASEVIDHEIGHT
);
}
else
return
SDL_FALSE
;
}
}
else
return
SDL_FALSE
;
SDL_RenderSetLogicalSize
(
renderer
,
BASEVIDWIDTH
,
BASEVIDHEIGHT
)
;
}
}
return
SDL_TRUE
;
return
SDL_TRUE
;
...
...
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