1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

SDL platform improvements

This commit is contained in:
Brian Fiete 2022-11-10 06:37:55 -08:00
parent d20b53b187
commit 8e191b074b
101 changed files with 37801 additions and 68 deletions

View file

@ -10,6 +10,11 @@
#define BF_IMPORT extern "C"
#if (defined(__arm__) || defined(__aarch64__))
#define BF_PLATFORM_OPENGL_ES2
#define BF_PLATFORM_ARM
#endif
#ifdef BFSYSLIB_DYNAMIC
#define BF_EXPORT extern "C"
#define BF_CALLTYPE

View file

@ -28,10 +28,6 @@
//#define offsetof(type, member) __builtin_offsetof (type, member)
#ifdef __arm__
#define BF_PLATFORM_OPENGL_ES2
#endif
extern "C"
{
//#define FFI_BUILDING

View file

@ -642,6 +642,7 @@ Texture* GLRenderDevice::LoadTexture(ImageData* imageData, int flags)
glTexture->mWidth = imageData->mWidth;
glTexture->mHeight = imageData->mHeight;
glTexture->mImageData = imageData;
glTexture->AddRef();
imageData->AddRef();
return glTexture;

View file

@ -17,7 +17,8 @@ SdlBFWindow::SdlBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
if (windowFlags & BFWINDOW_RESIZABLE)
sdlWindowFlags |= SDL_WINDOW_RESIZABLE;
sdlWindowFlags |= SDL_WINDOW_OPENGL;
if (windowFlags & BFWINDOW_FULLSCREEN)
sdlWindowFlags |= SDL_WINDOW_FULLSCREEN;
#ifdef BF_PLATFORM_FULLSCREEN
sdlWindowFlags |= SDL_WINDOW_FULLSCREEN;
#endif
@ -32,19 +33,23 @@ SdlBFWindow::SdlBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
if (!SDL_GL_CreateContext(mSDLWindow))
{
BF_FATAL(StrFormat(
String str = StrFormat(
#ifdef BF_PLATFORM_OPENGL_ES2
"Unable to create OpenGLES context: %s"
"Unable to create SDL OpenGLES context: %s"
#else
"Unable to create OpenGL context: %s"
"Unable to create SDL OpenGL context: %s"
#endif
, SDL_GetError()).c_str());
, SDL_GetError());
BF_FATAL(str.c_str());
SDL_Quit();
exit(2);
}
#ifndef BF_PLATFORM_OPENGL_ES2
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
#endif
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@ -236,32 +241,47 @@ void SdlBFApp::Run()
case SDL_MOUSEBUTTONUP:
{
SdlBFWindow* sdlBFWindow = GetSdlWindowFromId(sdlEvent.button.windowID);
sdlBFWindow->mMouseUpFunc(sdlBFWindow, sdlEvent.button.x, sdlEvent.button.y, sdlEvent.button.button);
if (sdlBFWindow != NULL)
sdlBFWindow->mMouseUpFunc(sdlBFWindow, sdlEvent.button.x, sdlEvent.button.y, sdlEvent.button.button);
}
break;
case SDL_MOUSEBUTTONDOWN:
{
SdlBFWindow* sdlBFWindow = GetSdlWindowFromId(sdlEvent.button.windowID);
sdlBFWindow->mMouseDownFunc(sdlBFWindow, sdlEvent.button.x, sdlEvent.button.y, sdlEvent.button.button, 1);
if (sdlBFWindow != NULL)
sdlBFWindow->mMouseDownFunc(sdlBFWindow, sdlEvent.button.x, sdlEvent.button.y, sdlEvent.button.button, 1);
}
break;
case SDL_MOUSEMOTION:
{
SdlBFWindow* sdlBFWindow = GetSdlWindowFromId(sdlEvent.button.windowID);
sdlBFWindow->mMouseMoveFunc(sdlBFWindow, sdlEvent.button.x, sdlEvent.button.y);
if (sdlBFWindow != NULL)
sdlBFWindow->mMouseMoveFunc(sdlBFWindow, sdlEvent.button.x, sdlEvent.button.y);
}
break;
case SDL_KEYDOWN:
{
SdlBFWindow* sdlBFWindow = GetSdlWindowFromId(sdlEvent.key.windowID);
sdlBFWindow->mKeyDownFunc(sdlBFWindow, SDLConvertScanCode(sdlEvent.key.keysym.scancode), sdlEvent.key.repeat);
sdlBFWindow->mKeyCharFunc(sdlBFWindow, sdlEvent.key.keysym.sym);
if (sdlBFWindow != NULL)
{
sdlBFWindow->mKeyDownFunc(sdlBFWindow, SDLConvertScanCode(sdlEvent.key.keysym.scancode), sdlEvent.key.repeat);
}
}
break;
case SDL_TEXTINPUT:
{
SdlBFWindow* sdlBFWindow = GetSdlWindowFromId(sdlEvent.key.windowID);
if (sdlBFWindow != NULL)
{
sdlBFWindow->mKeyCharFunc(sdlBFWindow, *(wchar_t*)sdlEvent.text.text);
}
}
break;
case SDL_KEYUP:
{
SdlBFWindow* sdlBFWindow = GetSdlWindowFromId(sdlEvent.key.windowID);
sdlBFWindow->mKeyUpFunc(sdlBFWindow, SDLConvertScanCode(sdlEvent.key.keysym.scancode));
if (sdlBFWindow != NULL)
sdlBFWindow->mKeyUpFunc(sdlBFWindow, SDLConvertScanCode(sdlEvent.key.keysym.scancode));
}
break;
}

View file

@ -11,8 +11,6 @@ NS_BF_BEGIN;
class RenderDevice;
typedef std::map<String, uint32> StringToUIntMap;
class SdlBFWindow : public BFWindow
{
public:
@ -54,7 +52,6 @@ class SdlBFApp : public BFApp
{
public:
bool mInMsgProc;
StringToUIntMap mClipboardFormatMap;
SdlWindowMap mSdlWindowMap;
protected: