1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Improved SDL platform support, 'ar' lib reworking

This commit is contained in:
Brian Fiete 2022-11-07 09:57:27 -08:00
parent 258a6653f9
commit d20b53b187
16 changed files with 488 additions and 385 deletions

View file

@ -7,7 +7,9 @@
USING_NS_BF;
#ifndef NOT_IMPL
#define NOT_IMPL throw "Not implemented"
#endif
#pragma comment(lib, "SDL2.lib")
@ -138,7 +140,7 @@ static void CreateOrthographicOffCenter(float left, float right, float bottom, f
GLShaderParam::GLShaderParam()
{
mGLVariable = NULL;
mGLVariable = 0;
}
GLShaderParam::~GLShaderParam()
@ -229,9 +231,6 @@ GLDrawBatch::GLDrawBatch() : DrawBatch()
GLDrawBatch::~GLDrawBatch()
{
delete mVertices;
delete mIndices;
//mGLBuffer->Release();
}
extern int gBFDrawBatchCount;
@ -311,60 +310,6 @@ void GLDrawLayer::SetShaderConstantData(int usageIdx, int slotIdx, void* constDa
{
}
/*void GLDrawLayer::FreeBatch(DrawBatch* drawBatch)
{
//delete drawBatch;
GLDrawBatch* batch = (GLDrawBatch*) drawBatch;
batch->Clear();
//GLDrawBatchVector* pool = &((GLRenderDevice*) gBFApp->mRenderDevice)->mDrawBatchPool;
//pool->push_back(batch);
GLRenderDevice* glRenderDevice = (GLRenderDevice*)gBFApp->mRenderDevice;
drawBatch->mNext = glRenderDevice->mFreeBatchHead;
glRenderDevice->mFreeBatchHead = batch;
}*/
//void GLRenderDevice::PhysSetShader(Shader* shader)
//{
// GLRenderDevice* aRenderDevice = (GLRenderDevice*) gBFApp->mRenderDevice;
//
// //TODO: Cache more
//
// GLShader* glShader = (GLShader*)shader;
//
// GLfloat matrix[4][4];
// CreateOrthographicOffCenter(0.0f, (float)mPhysRenderWindow->mWidth, (float)mPhysRenderWindow->mHeight, 0.0f, -100.0f, 100.0f, matrix);
// GLint matrixLoc = bf_glGetUniformLocation(glShader->mGLProgram, "screenMatrix");
// //BF_ASSERT(matrixLoc >= 0);
// if (matrixLoc >= 0)
// bf_glUniformMatrix4fv(matrixLoc, 1, false, (float*)matrix);
//
// /*mPhysShaderPass = shaderPass;
// GLShaderPass* dXShaderPass = (GLShaderPass*) mPhysShaderPass;
// mGLDevice->IASetInputLayout(dXShaderPass->mGLLayout);
//
// if (mCurShader->mLastResizeCount != mCurRenderTarget->mResizeNum)
// {
// ShaderParam* shaderParam = mCurShader->GetShaderParam(L"WindowSize");
// if (shaderParam != NULL)
// {
// shaderParam->SetFloat2((float) mCurRenderTarget->mWidth, (float) mCurRenderTarget->mHeight);
// }
//
// mCurShader->mLastResizeCount = mCurRenderTarget->mResizeNum;
// }
//
// GLCHECK(dXShaderPass->mGLEffectPass->Apply(0));*/
//
// /*GLfloat matrix[4][4];
// CreateOrthographicOffCenter(0.0f, (float)mPhysRenderWindow->mWidth, (float)mPhysRenderWindow->mHeight, 0.0f, -100.0f, 100.0f, matrix);
// GLint uniformLocation = bf_glGetUniformLocation(((GLShader*)shaderPass->mTechnique->mShader)->mGLProgram, "screenMatrix");
// if (uniformLocation != -1)
// bf_glUniformMatrix4fv(uniformLocation, 1, false, (GLfloat*)matrix);*/
//}
void GLRenderDevice::PhysSetRenderWindow(RenderWindow* renderWindow)
{
mCurRenderTarget = renderWindow;

View file

@ -117,9 +117,6 @@ class GLRenderWindow : public RenderWindow
public:
SDL_Window* mSDLWindow;
GLRenderDevice* mRenderDevice;
//IGLGISwapChain* mGLSwapChain;
//IGL10Texture2D* mGLBackBuffer;
//IGL10RenderTargetView* mGLRenderTargetView;
bool mResizePending;
int mPendingWidth;
int mPendingHeight;
@ -138,18 +135,9 @@ public:
void CopyBitsTo(uint32* dest, int width, int height);
};
typedef std::vector<GLDrawBatch*> GLDrawBatchVector;
class GLRenderDevice : public RenderDevice
{
public:
//IGLGIFactory* mGLGIFactory;
//IGL10Device* mGLDevice;
//IGL10BlendState* mGLNormalBlendState;
//IGL10BlendState* mGLAdditiveBlendState;
//IGL10RasterizerState* mGLRasterizerStateClipped;
//IGL10RasterizerState* mGLRasterizerStateUnclipped;
GLuint mGLVAO;
GLuint mGLVertexBuffer;
GLuint mGLIndexBuffer;
@ -158,7 +146,6 @@ public:
bool mHasVSync;
GLDrawBatchVector mDrawBatchPool;
GLDrawBatch* mFreeBatchHead;
public:

View file

@ -24,13 +24,21 @@ SdlBFWindow::SdlBFWindow(BFWindow* parent, const StringImpl& title, int x, int y
mSDLWindow = SDL_CreateWindow(title.c_str(), x, y, width, height, sdlWindowFlags);
#ifndef BF_PLATFORM_OPENGL_ES2
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);
#endif
if (!SDL_GL_CreateContext(mSDLWindow))
{
BF_FATAL(StrFormat("Unable to create OpenGL context: %s", SDL_GetError()).c_str());
BF_FATAL(StrFormat(
#ifdef BF_PLATFORM_OPENGL_ES2
"Unable to create OpenGLES context: %s"
#else
"Unable to create OpenGL context: %s"
#endif
, SDL_GetError()).c_str());
SDL_Quit();
exit(2);
}
@ -324,7 +332,7 @@ void SdlBFWindow::SetAlpha(float alpha, uint32 destAlphaSrcMask, bool isMouseVis
uint32 SdlBFApp::GetClipboardFormat(const StringImpl& format)
{
return CF_TEXT;
return /*CF_TEXT*/1;
}
void* SdlBFApp::GetClipboardData(const StringImpl& format, int* size)