Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Richard Gobeille
EDuke32
Commits
a7b1bccd
Commit
a7b1bccd
authored
Apr 21, 2022
by
Richard Gobeille
Browse files
engine: fix building with SDL 1.2
parent
4f1e9ab8
Changes
3
Hide whitespace changes
Inline
Side-by-side
GNUmakefile
View file @
a7b1bccd
...
...
@@ -248,7 +248,11 @@ engine_obj := $(obj)/$(engine)
engine_cflags
:=
-I
$(engine_src)
-I
$(mimalloc_inc)
-I
$(imgui_inc)
engine_deps
:=
mimalloc imgui
engine_deps
:=
mimalloc
ifneq
(1,$(SDL_TARGET))
engine_deps
+=
imgui
endif
ifneq
(0,$(USE_PHYSFS))
engine_deps
+=
physfs
...
...
source/build/src/build.cpp
View file @
a7b1bccd
...
...
@@ -3598,7 +3598,12 @@ void editorMaybeWarpMouse(int searchx, int searchy)
// force g_mouseAbs here because we seem to get a frame of rendering with the old values
// despite pumping the SDL event queue immediately after SDL_WarpMouseInWindow
g_mouseAbs
=
{
searchx
*
upscalefactor
,
searchy
*
upscalefactor
};
#if SDL_MAJOR_VERSION >= 2
SDL_WarpMouseInWindow
(
NULL
,
searchx
*
upscalefactor
,
searchy
*
upscalefactor
);
#else
// this would be FIXME if anyone gave a shit about using the editor with SDL 1.2
SDL_WarpMouse
(
searchx
*
upscalefactor
,
searchy
*
upscalefactor
);
#endif
handleevents
();
mouseLockToWindow
(
0
);
#endif
...
...
source/build/src/sdlayer.cpp
View file @
a7b1bccd
...
...
@@ -15,15 +15,18 @@
#include "sdl_inc.h"
#include "softsurface.h"
#if SDL_MAJOR_VERSION >= 2
# include "imgui.h"
# include "imgui_impl_sdl.h"
#ifdef USE_OPENGL
# include "imgui_impl_opengl3.h"
#endif
#endif
#ifdef USE_OPENGL
# include "glad/glad.h"
# include "glbuild.h"
# include "glsurface.h"
# include "imgui_impl_opengl3.h"
#endif
#if defined HAVE_GTK2
...
...
@@ -121,11 +124,11 @@ static SDL_Surface *loadappicon(void);
#endif
static
mutex_t
m_initprintf
;
#if SDL_MAJOR_VERSION >= 2
static
ImGuiIO
*
g_ImGui_IO
;
bool
g_ImGuiCaptureInput
=
true
;
#endif
uint8_t
g_ImGuiCapturedDevices
;
#ifdef _WIN32
# if SDL_MAJOR_VERSION >= 2
//
...
...
@@ -1289,7 +1292,9 @@ void mouseGrabInput(bool grab)
void
mouseLockToWindow
(
char
a
)
{
#if SDL_MAJOR_VERSION >= 2
if
(
!
g_ImGui_IO
||
!
g_ImGui_IO
->
WantCaptureMouse
)
#endif
if
(
!
(
a
&
2
))
{
mouseGrabInput
(
a
);
...
...
@@ -1300,6 +1305,7 @@ void mouseLockToWindow(char a)
SDL_ShowCursor
(
newstate
);
#if SDL_MAJOR_VERSION >= 2
if
(
g_ImGui_IO
)
{
if
(
newstate
)
...
...
@@ -1307,6 +1313,7 @@ void mouseLockToWindow(char a)
else
g_ImGui_IO
->
ConfigFlags
|=
ImGuiConfigFlags_NoMouseCursorChange
;
}
#endif
}
...
...
@@ -1506,33 +1513,40 @@ bool g_ImGuiFrameActive;
void
engineBeginImGuiFrame
(
void
)
{
Bassert
(
g_ImGuiFrameActive
==
false
);
#if SDL_MAJOR_VERSION >= 2
#ifdef USE_OPENGL
ImGui_ImplOpenGL3_NewFrame
();
#endif
ImGui_ImplSDL2_NewFrame
();
ImGui
::
NewFrame
();
g_ImGuiFrameActive
=
true
;
#endif
}
void
engineEndImGuiInput
(
void
)
{
keyFlushChars
();
keyFlushScans
();
#if SDL_MAJOR_VERSION >= 2
ImGui
::
GetIO
().
ClearInputKeys
();
// ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
SDL_StopTextInput
();
#endif
}
void
engineBeginImGuiInput
(
void
)
{
keyFlushChars
();
keyFlushScans
();
#if SDL_MAJOR_VERSION >= 2
SDL_StartTextInput
();
// ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange;
#endif
}
void
engineSetupImGui
(
void
)
{
#if SDL_MAJOR_VERSION >= 2
IMGUI_CHECKVERSION
();
ImGui
::
CreateContext
();
g_ImGui_IO
=
&
ImGui
::
GetIO
();
...
...
@@ -1551,6 +1565,7 @@ void engineSetupImGui(void)
g_ImGui_IO
->
Fonts
->
AddFontDefault
();
//ImFont* font = g_ImGui_IO->Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\consola.ttf", 12.0f);
//IM_ASSERT(font != NULL);
#endif
}
#ifdef USE_OPENGL
...
...
@@ -1990,14 +2005,14 @@ void videoShowFrame(int32_t w)
{
glsurface_blitBuffer
();
}
#if SDL_MAJOR_VERSION >= 2
if
(
g_ImGuiFrameActive
)
{
ImGui
::
Render
();
ImGui_ImplOpenGL3_RenderDrawData
(
ImGui
::
GetDrawData
());
g_ImGuiFrameActive
=
false
;
}
#endif
if
((
r_glfinish
==
1
&&
r_finishbeforeswap
==
1
)
||
vsync_renderlayer
==
2
)
{
MICROPROFILE_SCOPEI
(
"Engine"
,
"glFinish"
,
MP_GREEN
);
...
...
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