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

SDL/OGL platform improvements

This commit is contained in:
Brian Fiete 2022-11-03 10:58:24 -07:00
parent 213aea8c82
commit 258a6653f9
16 changed files with 711 additions and 1141 deletions

View file

@ -164,7 +164,6 @@ DrawLayer::DrawLayer()
DrawLayer::~DrawLayer()
{
NOP;
}
void DrawLayer::CloseDrawBatch()

View file

@ -265,24 +265,28 @@ FTFontManager::Glyph* FTFont::AllocGlyph(int charCode, bool allowDefault)
if (page->mTexture == NULL)
{
ImageData img;
img.CreateNew(FT_PAGE_WIDTH, FT_PAGE_HEIGHT);
ImageData* img = new ImageData();
img->CreateNew(FT_PAGE_WIDTH, FT_PAGE_HEIGHT);
auto* bits = img->mBits;
for (int i = 0; i < FT_PAGE_HEIGHT * FT_PAGE_WIDTH; i++)
{
if (i % 3 == 0)
img.mBits[i] = 0xFFFF0000;
bits[i] = 0xFFFF0000;
else if (i % 3 == 1)
img.mBits[i] = 0xFF00FF00;
bits[i] = 0xFF00FF00;
else
img.mBits[i] = 0xFF0000FF;
bits[i] = 0xFF0000FF;
}
page->mTexture = gBFApp->mRenderDevice->LoadTexture(&img, TextureFlag_NoPremult);
page->mTexture = gBFApp->mRenderDevice->LoadTexture(img, TextureFlag_NoPremult);
img->Deref();
}
if (bitmap.width > 0)
{
ImageData img;
img.CreateNew(bitmap.width, bitmap.rows);
ImageData* img = new ImageData();
img->CreateNew(bitmap.width, bitmap.rows);
auto* bits = img->mBits;
int width = img->mWidth;
for (int y = 0; y < (int)bitmap.rows; y++)
{
for (int x = 0; x < (int)bitmap.width; x++)
@ -292,11 +296,12 @@ FTFontManager::Glyph* FTFont::AllocGlyph(int charCode, bool allowDefault)
uint8 whiteVal = gFTFontManager.mWhiteTab[val];
uint8 blackVal = gFTFontManager.mBlackTab[val];
img.mBits[y * img.mWidth + x] = ((int32)whiteVal << 24) |
bits[y * width + x] = ((int32)whiteVal << 24) |
((int32)blackVal) | ((int32)0xFF << 8) | ((int32)0xFF << 16);
}
}
page->mTexture->Blt(&img, page->mCurX, page->mCurY);
page->mTexture->Blt(img, page->mCurX, page->mCurY);
img->Deref();
}
page->mCurX += bitmap.width;

View file

@ -164,7 +164,7 @@ Texture* RenderDevice::LoadTexture(const StringImpl& fileName, int flags)
if (!failed)
aTexture = LoadTexture(imageData, flags);
delete imageData;
imageData->Deref();
return aTexture;
}

View file

@ -20,14 +20,27 @@ ImageData::ImageData()
mAlphaPremultiplied = false;
mIsAdditive = false;
mSrcDataLen = 0;
mRefCount = 1;
}
ImageData::~ImageData()
{
BF_ASSERT(mRefCount <= 1); // Allow direct delete if we only have one reference
delete [] mBits;
delete [] mSrcData;
}
void ImageData::AddRef()
{
mRefCount++;
}
void ImageData::Deref()
{
if (--mRefCount == 0)
delete this;
}
void ImageData::SwapRAndB()
{
int aSize = mWidth*mHeight;

View file

@ -15,6 +15,7 @@ enum
class ImageData
{
public:
int mRefCount;
int mX;
int mY;
int mWidth;
@ -36,6 +37,8 @@ public:
ImageData();
virtual ~ImageData();
void AddRef();
void Deref();
void SwapRAndB();
void CreateNew(int x, int y, int width, int height, bool clear = true);
void CreateNew(int width, int height, bool clear = true);

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,12 @@
#pragma once
#include "Common.h"
#include "util/Dictionary.h"
#ifdef BF_PLATFORM_OPENGL_ES2
#include "SDL_opengles2.h"
#include <SDL2/SDL_opengles2.h>
#else
#include "SDL_opengl.h"
#include <SDL2/SDL_opengl.h>
#endif
#include "gfx/Shader.h"
@ -26,6 +27,7 @@ public:
GLRenderDevice* mRenderDevice;
GLuint mGLTexture;
GLuint mGLTexture2;
ImageData* mImageData;
//IGL10RenderTargetView* mGLRenderTargetView;
public:
@ -33,6 +35,7 @@ public:
~GLTexture();
virtual void PhysSetAsTarget();
virtual void Blt(ImageData* imageData, int x, int y) override;
};
class GLShaderParam : public ShaderParam
@ -48,7 +51,7 @@ public:
virtual void SetFloat4(float x, float y, float z, float w) override;
};
typedef std::map<String, GLShaderParam*> GLShaderParamMap;
typedef Dictionary<String, GLShaderParam*> GLShaderParamMap;
class GLShader : public Shader
{
@ -73,25 +76,36 @@ public:
virtual ShaderParam* GetShaderParam(const StringImpl& name) override;
};
class GLSetTextureCmd : public RenderCmd
{
public:
int mTextureIdx;
Texture* mTexture;
public:
virtual void Render(RenderDevice* renderDevice, RenderWindow* renderWindow) override;
};
class GLDrawBatch : public DrawBatch
{
public:
//IGL10Buffer* mGLBuffer;
public:
GLDrawBatch(int minVtxSize = 0, int minIdxSize = 0);
GLDrawBatch();
~GLDrawBatch();
virtual void Lock();
virtual void Draw();
//virtual void Lock();
virtual void Render(RenderDevice* renderDevice, RenderWindow* renderWindow) override;
};
class GLDrawLayer : public DrawLayer
{
public:
virtual DrawBatch* CreateDrawBatch();
virtual DrawBatch* AllocateBatch(int minVtxCount, int minIdxCount) override;
virtual void FreeBatch(DrawBatch* drawBatch) override;
virtual RenderCmd* CreateSetTextureCmd(int textureIdx, Texture* texture) override;
virtual void SetShaderConstantData(int usageIdx, int slotIdx, void* constData, int size) override;
public:
GLDrawLayer();
@ -136,9 +150,11 @@ public:
//IGL10RasterizerState* mGLRasterizerStateClipped;
//IGL10RasterizerState* mGLRasterizerStateUnclipped;
GLuint mGLVAO;
GLuint mGLVertexBuffer;
GLuint mGLIndexBuffer;
GLuint mBlankTexture;
GLShader* mCurShader;
bool mHasVSync;
@ -146,10 +162,11 @@ public:
GLDrawBatch* mFreeBatchHead;
public:
virtual void PhysSetAdditive(bool additive);
virtual void PhysSetShader(Shader* shaderPass);
//virtual void PhysSetAdditive(bool additive);
//virtual void PhysSetShader(Shader* shaderPass);
virtual void PhysSetRenderWindow(RenderWindow* renderWindow);
virtual void PhysSetRenderTarget(Texture* renderTarget);
virtual void PhysSetRenderState(RenderState* renderState) override;
virtual void PhysSetRenderTarget(Texture* renderTarget) override;
public:
GLRenderDevice();
@ -159,13 +176,16 @@ public:
void FrameStart() override;
void FrameEnd() override;
Texture* LoadTexture(ImageData* imageData, bool additive) override;
Shader* LoadShader(const StringImpl& fileName) override;
Texture* LoadTexture(ImageData* imageData, int flags) override;
Shader* LoadShader(const StringImpl& fileName, VertexDefinition* vertexDefinition) override;
Texture* CreateRenderTarget(int width, int height, bool destAlpha) override;
void SetShader(Shader* shader) override;
virtual Texture* CreateDynTexture(int width, int height) override { return NULL; }
virtual void SetRenderState(RenderState* renderState) override;
/*void SetShader(Shader* shader) override;
virtual void SetClip(float x, float y, float width, float height) override;
virtual void DisableClip() override;
virtual void DisableClip() override;*/
};
NS_BF_END;

View file

@ -1,6 +1,7 @@
#include "SdlBFApp.h"
#include "GLRenderDevice.h"
#include "SDL.h"
#include "platform/PlatformHelper.h"
#include <SDL2/SDL.h>
USING_NS_BF;
@ -9,6 +10,7 @@ USING_NS_BF;
#pragma comment(lib, "imm32.lib")
#pragma comment(lib, "version.lib")
SdlBFWindow::SdlBFWindow(BFWindow* parent, const StringImpl& title, int x, int y, int width, int height, int windowFlags)
{
int sdlWindowFlags = 0;
@ -22,6 +24,10 @@ SdlBFWindow::SdlBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
mSDLWindow = SDL_CreateWindow(title.c_str(), x, y, width, height, sdlWindowFlags);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
if (!SDL_GL_CreateContext(mSDLWindow))
{
BF_FATAL(StrFormat("Unable to create OpenGL context: %s", SDL_GetError()).c_str());
@ -29,19 +35,16 @@ SdlBFWindow::SdlBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
exit(2);
}
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#ifndef BF_PLATFORM_OPENGL_ES2
glEnableClientState(GL_INDEX_ARRAY);
//glEnableClientState(GL_INDEX_ARRAY);
#endif
//glEnableClientState(GL_VERTEX_ARRAY);
//glEnableClientState(GL_TEXTURE_COORD_ARRAY);
//glEnableClientState(GL_COLOR_ARRAY);
mIsMouseInside = false;
mRenderWindow = new GLRenderWindow((GLRenderDevice*)gBFApp->mRenderDevice, mSDLWindow);
mRenderWindow->mWindow = this;
@ -60,321 +63,13 @@ SdlBFWindow::~SdlBFWindow()
bool SdlBFWindow::TryClose()
{
SdlBFApp* app = (SdlBFApp*)gBFApp;
SdlWindowMap::iterator itr = app->mSdlWindowMap.find(SDL_GetWindowID(mSDLWindow));
app->mSdlWindowMap.erase(itr);
app->mSdlWindowMap.Remove(SDL_GetWindowID(mSDLWindow));
SDL_DestroyWindow(mSDLWindow);
mSDLWindow = NULL;
return true;
}
//LRESULT SdlBFWindow::WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
//{
// SdlBFApp* app = (SdlBFApp*) gBFApp;
//
// switch (Msg)
// {
// case WM_CLOSE:
// {
// if (mCloseQueryFunc(this) != 0)
// gBFApp->RemoveWindow(this);
// return 0;
// }
// break;
// case WM_DESTROY:
// /*if (mFlags & BFWINDOW_QUIT_ON_CLOSE)
// {
// gBFApp->mRunning = false;
// }*/
// mHWnd = NULL;
// break;
// }
//
// LRESULT result = 0;
// bool doResult = false;
//
// if (!app->mInMsgProc)
// {
// app->mInMsgProc = true;
//
// switch (Msg)
// {
//
// case WM_SIZE:
// mRenderWindow->Resized();
// if (mMovedFunc != NULL)
// mMovedFunc(this);
// break;
// case WM_PAINT:
// break;
// case WM_LBUTTONDOWN:
// case WM_RBUTTONDOWN:
// case WM_MBUTTONDOWN:
// case WM_LBUTTONDBLCLK:
// case WM_RBUTTONDBLCLK:
// case WM_LBUTTONUP:
// case WM_RBUTTONUP:
// case WM_MBUTTONUP:
// case WM_MOUSEWHEEL:
// case WM_MOUSEMOVE:
// {
// int x = (short) LOWORD(lParam);
// int y = (short) HIWORD(lParam);
//
// bool releaseCapture = false;
//
// POINT point = {x, y};
// ::ClientToScreen(hWnd, &point);
// HWND windowAtPoint = ::WindowFromPoint(point);
//
// bool isMouseOver = windowAtPoint == hWnd;
//
// if ((!mIsMouseInside) && (isMouseOver))
// {
// TRACKMOUSEEVENT tme;
// tme.cbSize = sizeof(TRACKMOUSEEVENT);
// tme.dwFlags = TME_LEAVE;
// tme.hwndTrack = hWnd;
// TrackMouseEvent(&tme);
// mIsMouseInside = true;
// }
//
// if ((mIsMouseInside) && (!isMouseOver))
// {
// mIsMouseInside = false;
// mMouseLeaveFunc(this);
// }
//
// switch (Msg)
// {
// case WM_LBUTTONDOWN:
// SetCapture(hWnd);
// mMouseDownFunc(this, x, y, 0, 1);
// break;
// case WM_RBUTTONDOWN:
// SetCapture(hWnd);
// mMouseDownFunc(this, x, y, 1, 1);
// break;
// case WM_MBUTTONDOWN:
// SetCapture(hWnd);
// mMouseDownFunc(this, x, y, 2, 1);
// break;
// case WM_LBUTTONDBLCLK:
// SetCapture(hWnd);
// mMouseDownFunc(this, x, y, 0, 2);
// break;
// case WM_RBUTTONDBLCLK:
// SetCapture(hWnd);
// mMouseDownFunc(this, x, y, 1, 2);
// break;
// case WM_MBUTTONDBLCLK:
// SetCapture(hWnd);
// mMouseDownFunc(this, x, y, 2, 2);
// break;
// case WM_LBUTTONUP:
// releaseCapture = true;
// mMouseUpFunc(this, x, y, 0);
// break;
// case WM_RBUTTONUP:
// releaseCapture = true;
// mMouseUpFunc(this, x, y, 1);
// break;
// case WM_MBUTTONUP:
// releaseCapture = true;
// mMouseUpFunc(this, x, y, 2);
// break;
// case WM_MOUSEWHEEL:
// {
// POINT pt = {x, y};
// ScreenToClient(mHWnd, &pt);
//
// int delta = ((int16)HIWORD(wParam)) / 120;
// mMouseWheelFunc(this, pt.x, pt.y, delta);
// }
// break;
// case WM_MOUSEMOVE:
// {
// mMouseMoveFunc(this, x, y);
//
// if ((wParam != 0) && (gBFApp->mWindowList.size() > 1))
// {
// // See if our mouse is down and has entered into another window's space
// POINT point = {x, y};
// ::ClientToScreen(hWnd, &point);
//
// HWND windowAtPoint = ::WindowFromPoint(point);
//
// BFWindowList::iterator itr = gBFApp->mWindowList.begin();
// while (itr != gBFApp->mWindowList.end())
// {
// SdlBFWindow* aWindow = (SdlBFWindow*) *itr;
// if (aWindow != this)
// {
// if (aWindow->mHWnd == windowAtPoint)
// {
// POINT clientPt = point;
// ::ScreenToClient(aWindow->mHWnd, &clientPt);
// aWindow->mMouseProxyMoveFunc(this, clientPt.x, clientPt.y);
// aWindow->mIsMouseInside = true;
// }
// else if (aWindow->mIsMouseInside)
// {
// aWindow->mMouseLeaveFunc(this);
// aWindow->mIsMouseInside = false;
// }
// }
// ++itr;
// }
// }
// }
// break;
// }
//
// if (releaseCapture)
// {
// ReleaseCapture();
//
// BFWindowList::iterator itr = gBFApp->mWindowList.begin();
// while (itr != gBFApp->mWindowList.end())
// {
// SdlBFWindow* aWindow = (SdlBFWindow*) *itr;
// if ((aWindow != this) && (aWindow->mIsMouseInside))
// {
// aWindow->mMouseLeaveFunc(this);
// aWindow->mIsMouseInside = false;
// }
// ++itr;
// }
// }
// }
// break;
//
// case WM_COMMAND:
// {
// SdlBFMenu* aMenu = mMenuIDMap[(uint32)wParam];
// if (aMenu != NULL)
// mMenuItemSelectedFunc(this, aMenu);
// }
// break;
// case WM_INITMENUPOPUP:
// {
// HMENU hMenu = (HMENU) wParam;
// SdlBFMenu* aMenu = mHMenuMap[hMenu];
// if (aMenu != NULL)
// mMenuItemSelectedFunc(this, aMenu);
// }
// break;
//
// case WM_MOUSEACTIVATE:
// if (mFlags & BFWINDOW_NO_MOUSE_ACTIVATE)
// {
// doResult = true;
// result = MA_NOACTIVATE;
// }
// break;
//
// case WM_KILLFOCUS:
// mLostFocusFunc(this);
// break;
// case WM_SETFOCUS:
// mGotFocusFunc(this);
// break;
// case WM_MOUSELEAVE:
// mIsMouseInside = false;
// mMouseLeaveFunc(this);
// break;
//
// case WM_CHAR:
// mKeyCharFunc(this, (WCHAR)wParam);
// break;
// case WM_SYSKEYDOWN:
// case WM_KEYDOWN:
// {
// int keyCode = (int) wParam;
// mIsKeyDown[keyCode] = true;
//
// WinMenuIDMap::iterator itr = mMenuIDMap.begin();
// while (itr != mMenuIDMap.end())
// {
// SdlBFMenu* aMenu = itr->second;
// if ((aMenu->mKeyCode == keyCode) &&
// (aMenu->mKeyShift == mIsKeyDown[VK_SHIFT]) &&
// (aMenu->mKeyCtrl == mIsKeyDown[VK_CONTROL]) &&
// (aMenu->mKeyAlt == mIsKeyDown[VK_MENU]))
// {
// mMenuItemSelectedFunc(this, aMenu);
// doResult = true;
// break;
// }
// ++itr;
// }
// mKeyDownFunc(this, (int) wParam, (lParam & 0x7FFF) != 0);
// }
// break;
// case WM_SYSCHAR:
// {
// int keyCode = toupper((int) wParam);
//
// WinMenuIDMap::iterator itr = mMenuIDMap.begin();
// while (itr != mMenuIDMap.end())
// {
// SdlBFMenu* aMenu = itr->second;
// if ((aMenu->mKeyCode == keyCode) &&
// (aMenu->mKeyShift == mIsKeyDown[VK_SHIFT]) &&
// (aMenu->mKeyCtrl == mIsKeyDown[VK_CONTROL]) &&
// (aMenu->mKeyAlt == mIsKeyDown[VK_MENU]))
// {
// doResult = true;
// break;
// }
// ++itr;
// }
// }
// break;
// case WM_SYSKEYUP:
// case WM_KEYUP:
// {
// int keyCode = (int) wParam;
// if (mIsKeyDown[keyCode])
// {
// mKeyUpFunc(this, (int) wParam);
// mIsKeyDown[keyCode] = false;
// }
// }
// break;
//
// case WM_TIMER:
// if (gBFApp->mSysDialogCnt == 0)
// gBFApp->Process();
// break;
//
// case WM_SETCURSOR:
// gBFApp->PhysSetCursor();
// break;
//
// case WM_MOVING:
// if (mMovedFunc != NULL)
// mMovedFunc(this);
// break;
// case WM_SIZING:
// mRenderWindow->Resized();
// if (mMovedFunc != NULL)
// mMovedFunc(this);
// if (gBFApp->mSysDialogCnt == 0)
// gBFApp->Process();
// break;
// }
//
//
// app->mInMsgProc = false;
// }
//
// if (doResult)
// return result;
//
// return DefWindowProc(hWnd, Msg, wParam, lParam);
//}
static int SDLConvertScanCode(int scanCode)
{
if ((scanCode >= SDL_SCANCODE_A) && (scanCode <= SDL_SCANCODE_Z))
@ -461,29 +156,20 @@ extern HINSTANCE gDLLInstance;
SdlBFApp::SdlBFApp()
{
//_CrtSetReportHook(SdlBFReportHook);
mRunning = false;
mRenderDevice = NULL;
wchar_t aStr[MAX_PATH];
#ifdef _WIN32
GetModuleFileNameW(gDLLInstance, aStr, MAX_PATH);
#else
GetModuleFileNameW(NULL, aStr, MAX_PATH);
#endif
if (aStr[0] == '!')
Beefy::String exePath;
BfpGetStrHelper(exePath, [](char* outStr, int* inOutStrSize, BfpResult* result)
{
new SdlBFWindow(NULL, "", 0, 0, 0, 0, 0);
}
BfpSystem_GetExecutablePath(outStr, inOutStrSize, (BfpSystemResult*)result);
});
mInstallDir = aStr;
mInstallDir = GetFileDir(exePath) + "/";
int lastSlash = std::max((int)mInstallDir.rfind('\\'), (int)mInstallDir.rfind('/'));
int lastSlash = std::max((int)mInstallDir.LastIndexOf('\\'), (int)mInstallDir.LastIndexOf('/'));
if (lastSlash != -1)
mInstallDir = mInstallDir.substr(0, lastSlash);
mInstallDir = mInstallDir.Substring(0, lastSlash);
//TODO: We're not properly using DataDir vs InstallDir
#if (!defined BFSYSLIB_DYNAMIC) && (defined BF_RESOURCES_REL_DIR)
@ -492,8 +178,6 @@ SdlBFApp::SdlBFApp()
mInstallDir += "/";
//OutputDebugStrF(L"DataDir: %s\n", mInstallDir.c_str());
mDataDir = mInstallDir;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) < 0)
@ -506,10 +190,9 @@ SdlBFApp::~SdlBFApp()
SdlBFWindow* SdlBFApp::GetSdlWindowFromId(uint32 id)
{
SdlWindowMap::iterator itr = mSdlWindowMap.find(id);
if (itr != mSdlWindowMap.end())
return itr->second;
return NULL;
SdlBFWindow* window = NULL;
mSdlWindowMap.TryGetValue(id, &window);
return window;
}
void SdlBFApp::Init()
@ -623,29 +306,7 @@ void SdlBFWindow::GetPosition(int* x, int* y, int* width, int* height, int* clie
void SdlBFApp::PhysSetCursor()
{
//
//static HCURSOR cursors [] =
// {
// ::LoadCursor(NULL, IDC_ARROW),
//
// //TODO: mApp->mHandCursor);
// ::LoadCursor(NULL, IDC_ARROW),
// //TODO: mApp->mDraggingCursor);
// ::LoadCursor(NULL, IDC_ARROW),
// ::LoadCursor(NULL, IDC_IBEAM),
//
// ::LoadCursor(NULL, IDC_NO),
// ::LoadCursor(NULL, IDC_SIZEALL),
// ::LoadCursor(NULL, IDC_SIZENESW),
// ::LoadCursor(NULL, IDC_SIZENS),
// ::LoadCursor(NULL, IDC_SIZENWSE),
// ::LoadCursor(NULL, IDC_SIZEWE),
// ::LoadCursor(NULL, IDC_WAIT),
// NULL
// };
//::SetCursor(cursors[mCursor]);
}
void SdlBFWindow::SetClientPosition(int x, int y)
@ -681,7 +342,7 @@ void SdlBFApp::SetClipboardData(const StringImpl& format, const void* ptr, int s
SDL_SetClipboardText((const char*)ptr);
}
BFMenu* SdlBFWindow::AddMenuItem(BFMenu* parent, const wchar_t* text, const wchar_t* hotKey, BFSysBitmap* sysBitmap, bool enabled, int checkState, bool radioCheck)
BFMenu* SdlBFWindow::AddMenuItem(BFMenu* parent, int insertIdx, const char* text, const char* hotKey, BFSysBitmap* bitmap, bool enabled, int checkState, bool radioCheck)
{
return NULL;
}
@ -709,17 +370,18 @@ DrawLayer* SdlBFApp::CreateDrawLayer(BFWindow* window)
drawLayer->mRenderWindow = window->mRenderWindow;
window->mRenderWindow->mDrawLayerList.push_back(drawLayer);
}
drawLayer->mRenderDevice = mRenderDevice;
return drawLayer;
}
void SdlBFApp::GetDesktopResolution(int& width, int& height) override
void SdlBFApp::GetDesktopResolution(int& width, int& height)
{
width = 1024;
height = 768;
}
void SdlBFApp::GetWorkspaceRect(int& x, int& y, int& width, int& height) override
void SdlBFApp::GetWorkspaceRect(int& x, int& y, int& width, int& height)
{
x = 0;
y = 0;

View file

@ -3,6 +3,7 @@
#include "BFApp.h"
#include "BFWindow.h"
#include <map>
#include "util/Dictionary.h"
struct SDL_Window;
@ -23,17 +24,31 @@ public:
SdlBFWindow(BFWindow* parent, const StringImpl& title, int x, int y, int width, int height, int windowFlags);
~SdlBFWindow();
virtual void* GetUnderlying() {return mSDLWindow; };
virtual void Destroy() { }
virtual void SetTitle(const char* title) override {}
virtual void SetMinimumSize(int minWidth, int minHeight, bool clientSized) override {}
virtual void GetPlacement(int* normX, int* normY, int* normWidth, int* normHeight, int* showKind) override { }
virtual void Resize(int x, int y, int width, int height, int showKind) override {}
virtual void SetMouseVisible(bool isMouseVisible) override {}
virtual bool TryClose() override;
virtual void GetPosition(int* x, int* y, int* width, int* height, int* clientX, int* clientY, int* clientWidth, int* clientHeight) override;
virtual void SetClientPosition(int x, int y) override;
virtual void SetAlpha(float alpha, uint32 destAlphaSrcMask, bool isMouseVisible) override;
virtual BFMenu* AddMenuItem(BFMenu* parent, const wchar_t* text, const wchar_t* hotKey, BFSysBitmap* sysBitmap, bool enabled, int checkState, bool radioCheck);
virtual BFMenu* AddMenuItem(BFMenu* parent, int insertIdx, const char* text, const char* hotKey, BFSysBitmap* bitmap, bool enabled, int checkState, bool radioCheck) override;
virtual void ModifyMenuItem(BFMenu* item, const char* text, const char* hotKey, BFSysBitmap* bitmap, bool enabled, int checkState, bool radioCheck) override {}
virtual void RemoveMenuItem(BFMenu* item) override;
virtual void LostFocus(BFWindow* newFocus) override {};
virtual void ModalsRemoved() override;
virtual void SetForeground() override {};
};
typedef std::map<uint32, SdlBFWindow*> SdlWindowMap;
typedef Dictionary<uint32, SdlBFWindow*> SdlWindowMap;
class SdlBFApp : public BFApp
{

10
IDE/dist/shaders/Std.frag vendored Normal file
View file

@ -0,0 +1,10 @@
uniform sampler2D tex;
uniform sampler2D tex2;
varying vec4 varying_color;
varying vec2 varying_texCoord0;
void main()
{
vec4 texColor = texture2D(tex, varying_texCoord0);
gl_FragColor = texColor * varying_color;
}

12
IDE/dist/shaders/Std_font.frag vendored Normal file
View file

@ -0,0 +1,12 @@
uniform sampler2D tex;
uniform sampler2D tex2;
varying vec4 varying_color;
varying vec2 varying_texCoord0;
void main()
{
vec4 texColor = texture2D(tex, varying_texCoord0);
float gray = varying_color.r * 0.299 + varying_color.g * 0.587 + varying_color.b * 0.114;
float a = mix(texColor.a, texColor.r, gray);
gl_FragColor = vec4(a, a, a, a) * varying_color;
}

15
IDE/dist/shaders/Std_font.vert vendored Normal file
View file

@ -0,0 +1,15 @@
uniform mat4 screenMatrix;
attribute vec4 position;
attribute vec2 texCoord0;
attribute vec4 color;
varying vec4 varying_color;
varying vec2 varying_texCoord0;
void main()
{
gl_Position = screenMatrix * position;
varying_color = vec4(color.b * color.a, color.g * color.a, color.r * color.a, color.a);
varying_texCoord0 = texCoord0;
}

14
IDE/dist/shaders/Std_font_es.frag vendored Normal file
View file

@ -0,0 +1,14 @@
precision lowp float;
uniform lowp sampler2D tex;
uniform lowp sampler2D tex2;
varying lowp vec4 varying_color;
varying mediump vec2 varying_texCoord0;
void main()
{
lowp vec4 texColor = texture2D(tex, varying_texCoord0);
float gray = varying_color.r * 0.299 + varying_color.g * 0.587 + varying_color.b * 0.114;
float a = mix(texColor.a, texColor.r, gray);
gl_FragColor = vec4(a, a, a, a) * varying_color;
}

17
IDE/dist/shaders/Std_font_es.vert vendored Normal file
View file

@ -0,0 +1,17 @@
precision mediump float;
uniform mat4 screenMatrix;
attribute vec4 position;
attribute vec2 texCoord0;
attribute vec4 color;
precision lowp float;
varying lowp vec4 varying_color;
varying mediump vec2 varying_texCoord0;
void main()
{
gl_Position = screenMatrix * position;
varying_color = vec4(color.b * color.a, color.g * color.a, color.r * color.a, color.a);
varying_texCoord0 = texCoord0;
}