mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Read-from-memory fixes, render target improvements
This commit is contained in:
parent
818ca48759
commit
60988fda8f
13 changed files with 87 additions and 17 deletions
|
@ -446,10 +446,11 @@ BF_EXPORT int BF_CALLTYPE BFWindow_GetDPI(BFWindow* window)
|
|||
|
||||
BF_EXPORT TextureSegment* BF_CALLTYPE Gfx_CreateRenderTarget(int width, int height, int destAlpha)
|
||||
{
|
||||
Texture* texture = gBFApp->mRenderDevice->CreateRenderTarget(width, height, destAlpha != 0);
|
||||
Texture* texture = gBFApp->mRenderDevice->CreateRenderTarget(width, height, destAlpha != 0);
|
||||
texture->mResetClear = true;
|
||||
|
||||
TextureSegment* aTextureSegment = new TextureSegment();
|
||||
aTextureSegment->InitFromTexture(texture);
|
||||
aTextureSegment->InitFromTexture(texture);
|
||||
return aTextureSegment;
|
||||
}
|
||||
|
||||
|
|
|
@ -1380,9 +1380,11 @@ void Beefy::BFFatalError(const char* message, const char* file, int line)
|
|||
BFFatalError(String(message), String(file), line);
|
||||
}
|
||||
|
||||
bool Beefy::ParseMemorySpan(const StringImpl& str, void*& outPtr, int& outSize)
|
||||
bool Beefy::ParseMemorySpan(const StringImpl& str, void*& outPtr, int& outSize, StringImpl* outKey)
|
||||
{
|
||||
#ifndef BF_SMALL
|
||||
static int anonymousIdx = 0;
|
||||
|
||||
if (str.StartsWith("@"))
|
||||
{
|
||||
int colon = (int)str.IndexOf(':');
|
||||
|
@ -1390,6 +1392,21 @@ bool Beefy::ParseMemorySpan(const StringImpl& str, void*& outPtr, int& outSize)
|
|||
String lenStr = str.Substring(colon + 1);
|
||||
outPtr = (void*)(intptr)strtoll(addrStr.c_str(), NULL, 16);
|
||||
outSize = (int)strtol(lenStr.c_str(), NULL, 10);
|
||||
|
||||
if (outKey != NULL)
|
||||
{
|
||||
int nextColon = (int)str.IndexOf(':', colon + 1);
|
||||
if (nextColon > 0)
|
||||
{
|
||||
*outKey = str.Substring(nextColon + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int dotPos = (int)str.IndexOf('.', colon + 1);
|
||||
*outKey = StrFormat("ANON_%d", anonymousIdx++) + str.Substring(dotPos);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -242,7 +242,7 @@ bool FileExists(const StringImpl& path, String* outActualName = NULL);
|
|||
bool DirectoryExists(const StringImpl& path, String* outActualName = NULL);
|
||||
bool RecursiveCreateDirectory(const StringImpl& dirName);
|
||||
bool RecursiveDeleteDirectory(const StringImpl& dirName);
|
||||
bool ParseMemorySpan(const StringImpl& str, void*& outPtr, int& outSize);
|
||||
bool ParseMemorySpan(const StringImpl& str, void*& outPtr, int& outSize, StringImpl* outKey = NULL);
|
||||
|
||||
#define CHARTAG(val) FromBIGEndian(val)
|
||||
|
||||
|
|
|
@ -136,13 +136,18 @@ bool FTFont::Load(const StringImpl& fileName, float pointSize)
|
|||
|
||||
FTFontManager::Face* face = NULL;
|
||||
|
||||
String key = fileName;
|
||||
void* memPtr = NULL;
|
||||
int memLen = 0;
|
||||
bool isMemory = ParseMemorySpan(fileName, memPtr, memLen, &key);
|
||||
|
||||
FTFontManager::Face** facePtr = NULL;
|
||||
if (gFTFontManager.mFaces.TryAdd(fileName, NULL, &facePtr))
|
||||
if (gFTFontManager.mFaces.TryAdd(key, NULL, &facePtr))
|
||||
{
|
||||
face = new FTFontManager::Face();
|
||||
*facePtr = face;
|
||||
|
||||
face->mFileName = fileName;
|
||||
face->mFileName = key;
|
||||
FT_Face ftFace = NULL;
|
||||
|
||||
String useFileName = fileName;
|
||||
|
@ -153,10 +158,8 @@ bool FTFont::Load(const StringImpl& fileName, float pointSize)
|
|||
faceIdx = atoi(useFileName.c_str() + atPos + 1);
|
||||
useFileName.RemoveToEnd(atPos);
|
||||
}
|
||||
|
||||
void* memPtr = NULL;
|
||||
int memLen = 0;
|
||||
if (ParseMemorySpan(fileName, memPtr, memLen))
|
||||
|
||||
if (isMemory)
|
||||
{
|
||||
FT_New_Memory_Face(gFTLibrary, (FT_Byte*)memPtr, memLen, faceIdx, &ftFace);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ RenderTarget::RenderTarget()
|
|||
mHasBeenDrawnTo = false;
|
||||
mHasBeenTargeted = false;
|
||||
mResizeNum = 0;
|
||||
mWantsClear = true;
|
||||
mResetClear = false;
|
||||
}
|
||||
|
||||
RenderWindow::RenderWindow()
|
||||
|
|
|
@ -12,6 +12,8 @@ public:
|
|||
int mResizeNum;
|
||||
bool mHasBeenTargeted;
|
||||
bool mHasBeenDrawnTo;
|
||||
bool mWantsClear;
|
||||
bool mResetClear;
|
||||
|
||||
public:
|
||||
RenderTarget();
|
||||
|
|
|
@ -648,7 +648,7 @@ void DXTexture::PhysSetAsTarget()
|
|||
mRenderDevice->mD3DDeviceContext->RSSetViewports(1, &viewPort);
|
||||
}
|
||||
|
||||
//if (!mHasBeenDrawnTo)
|
||||
if (mWantsClear)
|
||||
{
|
||||
float bgColor[4] = {1, (rand() % 256) / 256.0f, 0.5, 1};
|
||||
mRenderDevice->mD3DDeviceContext->ClearRenderTargetView(mD3DRenderTargetView, bgColor);
|
||||
|
@ -657,6 +657,8 @@ void DXTexture::PhysSetAsTarget()
|
|||
|
||||
//mRenderDevice->mD3DDevice->ClearRenderTargetView(mD3DRenderTargetView, D3DXVECTOR4(1, 0.5, 0.5, 1));
|
||||
mHasBeenDrawnTo = true;
|
||||
if (mResetClear)
|
||||
mWantsClear = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue