forked from Mirrors/openclonk
Stop pretending we support 16 bit color
The GTK and OS X platforms already ignored the requested bit depth and always used 32 bit. Windows and SDL would set a 16 bit color depth for the screen, but still did all of the rendering short of the final present in 32 bit.epoxy
parent
2000f741c3
commit
e9cf0f6fdc
|
@ -104,7 +104,6 @@ void C4ConfigGraphics::CompileFunc(StdCompiler *pComp)
|
|||
pComp->Value(mkNamingAdapt(ShowClock, "ShowClock", 0 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(ShowCrewNames, "ShowCrewNames", 1 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(ShowCrewCNames, "ShowCrewCNames", 0 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(BitDepth, "BitDepth", 32 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(Windowed, "Windowed", 0 ,false, true));
|
||||
pComp->Value(mkNamingAdapt(PXSGfx, "PXSGfx" , 1 ));
|
||||
pComp->Value(mkNamingAdapt(Gamma, "Gamma" , 100 ));
|
||||
|
@ -353,11 +352,6 @@ bool C4Config::Load(const char *szConfigFile)
|
|||
if (fWinSock) WSACleanup();
|
||||
#endif
|
||||
General.DefaultLanguage();
|
||||
// bit depth sanity check (might be corrupted by resolution check bug in old version)
|
||||
if (Graphics.BitDepth < 16)
|
||||
{
|
||||
Graphics.BitDepth = 32;
|
||||
}
|
||||
// Warning against invalid ports
|
||||
if (Config.Network.PortTCP>0 && Config.Network.PortTCP == Config.Network.PortRefServer)
|
||||
{
|
||||
|
|
|
@ -106,7 +106,6 @@ public:
|
|||
int32_t Windowed; // 0: fullscreen, 1: windowed, 2: fullscreen in game, windowed in menu
|
||||
int32_t ShowCrewNames; // show player name above clonks?
|
||||
int32_t ShowCrewCNames; // show clonk names above clonks?
|
||||
int32_t BitDepth; // used bit depth for newgfx
|
||||
int32_t PXSGfx; // show PXS-graphics (instead of sole pixels)
|
||||
int32_t Gamma; // gamma value
|
||||
int32_t Currency; // default wealth symbolseb
|
||||
|
|
|
@ -176,12 +176,12 @@ bool C4Application::DoInit(int argc, char * argv[])
|
|||
Add(pGameTimer = new C4ApplicationGameTimer());
|
||||
|
||||
// Initialize OpenGL
|
||||
bool success = DDrawInit(this, GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.Monitor);
|
||||
bool success = DDrawInit(this, GetConfigWidth(), GetConfigHeight(), Config.Graphics.Monitor);
|
||||
if (!success) { LogFatal(LoadResStr("IDS_ERR_DDRAW")); Clear(); ShowGfxErrorDialog(); return false; }
|
||||
|
||||
if (!isEditor)
|
||||
{
|
||||
if (!SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed))
|
||||
if (!SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed))
|
||||
pWindow->SetSize(Config.Graphics.WindowX, Config.Graphics.WindowY);
|
||||
}
|
||||
|
||||
|
@ -485,9 +485,9 @@ void C4Application::ApplyResolutionConstraints()
|
|||
uint32_t best_delta = ~0;
|
||||
while (GetIndexedDisplayMode(++idx, &iXRes, &iYRes, &iBitDepth, &iRefreshRate, Config.Graphics.Monitor))
|
||||
{
|
||||
if (iBitDepth != Config.Graphics.BitDepth) continue;
|
||||
if (iBitDepth != C4Draw::COLOR_DEPTH) continue;
|
||||
uint32_t delta = std::abs(Config.Graphics.ResX*Config.Graphics.ResY - iXRes*iYRes);
|
||||
if (!delta && iBitDepth == Config.Graphics.BitDepth && iRefreshRate == Config.Graphics.RefreshRate)
|
||||
if (!delta && iBitDepth == C4Draw::COLOR_DEPTH && iRefreshRate == Config.Graphics.RefreshRate)
|
||||
return; // Exactly the expected mode
|
||||
if (delta < best_delta)
|
||||
{
|
||||
|
@ -505,7 +505,6 @@ void C4Application::ApplyResolutionConstraints()
|
|||
// Also, lang table not loaded yet
|
||||
LogF("Warning: The selected resolution %dx%d is not available and has been changed to %dx%d.", Config.Graphics.ResX, Config.Graphics.ResY, iXRes, iYRes);
|
||||
Config.Graphics.ResX = iXRes; Config.Graphics.ResY = iYRes;
|
||||
Config.Graphics.BitDepth = iBitDepth;
|
||||
Config.Graphics.RefreshRate = iRefreshRate;
|
||||
}
|
||||
}
|
||||
|
@ -695,13 +694,13 @@ void C4Application::GameTick()
|
|||
break;
|
||||
}
|
||||
if(Config.Graphics.Windowed == 2 && FullScreenMode())
|
||||
Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, true);
|
||||
Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.RefreshRate, Config.Graphics.Monitor, true);
|
||||
break;
|
||||
case C4AS_AfterGame:
|
||||
// stop game
|
||||
Game.Clear();
|
||||
if(Config.Graphics.Windowed == 2 && !NextMission && !isEditor)
|
||||
Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, false);
|
||||
Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.RefreshRate, Config.Graphics.Monitor, false);
|
||||
AppState = C4AS_PreInit;
|
||||
// if a next mission is desired, set to start it
|
||||
if (NextMission)
|
||||
|
|
|
@ -818,7 +818,7 @@ void C4Draw::RemoveZoom(float & X, float & Y)
|
|||
Y = (Y - ZoomY) / Zoom + ZoomY;
|
||||
}
|
||||
|
||||
bool DDrawInit(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, int iBitDepth, unsigned int iMonitor)
|
||||
bool DDrawInit(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor)
|
||||
{
|
||||
// create engine
|
||||
#ifndef USE_CONSOLE
|
||||
|
@ -828,7 +828,7 @@ bool DDrawInit(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, int
|
|||
#endif
|
||||
if (!pDraw) return false;
|
||||
// init it
|
||||
if (!pDraw->Init(pApp, iXRes, iYRes, iBitDepth, iMonitor))
|
||||
if (!pDraw->Init(pApp, iXRes, iYRes, iMonitor))
|
||||
{
|
||||
delete pDraw;
|
||||
return false;
|
||||
|
@ -837,13 +837,13 @@ bool DDrawInit(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, int
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4Draw::Init(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, int iBitDepth, unsigned int iMonitor)
|
||||
bool C4Draw::Init(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor)
|
||||
{
|
||||
this->pApp = pApp;
|
||||
|
||||
pApp->pWindow->pSurface = new C4Surface(pApp, pApp->pWindow);
|
||||
|
||||
if (!CreatePrimarySurfaces(iXRes, iYRes, iBitDepth, iMonitor))
|
||||
if (!CreatePrimarySurfaces(iXRes, iYRes, iMonitor))
|
||||
return false;
|
||||
|
||||
if (!CreatePrimaryClipper(iXRes, iYRes))
|
||||
|
|
|
@ -136,6 +136,9 @@ class C4Draw
|
|||
public:
|
||||
enum DrawOperation { OP_POINTS, OP_TRIANGLES };
|
||||
|
||||
static constexpr int COLOR_DEPTH = 32;
|
||||
static constexpr int COLOR_DEPTH_BYTES = COLOR_DEPTH / 8;
|
||||
|
||||
C4Draw(): MaxTexSize(0) { }
|
||||
virtual ~C4Draw() { pDraw=NULL; }
|
||||
public:
|
||||
|
@ -145,7 +148,6 @@ public:
|
|||
float gammaOut[3]; // combined gamma
|
||||
int MaxTexSize;
|
||||
protected:
|
||||
BYTE byByteCnt; // bytes per pixel (2 or 4)
|
||||
float fClipX1,fClipY1,fClipX2,fClipY2; // clipper in unzoomed coordinates
|
||||
float fStClipX1,fStClipY1,fStClipX2,fStClipY2; // stored clipper in unzoomed coordinates
|
||||
int32_t iClipX1,iClipY1,iClipX2,iClipY2; // clipper in pixel coordinates
|
||||
|
@ -162,7 +164,7 @@ protected:
|
|||
public:
|
||||
float Zoom;
|
||||
// General
|
||||
bool Init(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, int iBitDepth, unsigned int iMonitor);
|
||||
bool Init(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor);
|
||||
virtual void Clear();
|
||||
virtual void Default();
|
||||
virtual CStdGLCtx *CreateContext(C4Window *, C4AbstractApp *) { return NULL; }
|
||||
|
@ -253,7 +255,7 @@ public:
|
|||
protected:
|
||||
bool StringOut(const char *szText, C4Surface * sfcDest, float iTx, float iTy, DWORD dwFCol, BYTE byForm, bool fDoMarkup, C4Markup &Markup, CStdFont *pFont, float fZoom);
|
||||
bool CreatePrimaryClipper(unsigned int iXRes, unsigned int iYRes);
|
||||
virtual bool CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor) = 0;
|
||||
virtual bool CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor) = 0;
|
||||
virtual bool Error(const char *szMsg);
|
||||
|
||||
friend class C4Surface;
|
||||
|
@ -268,5 +270,5 @@ struct ZoomDataStackItem: public ZoomData
|
|||
~ZoomDataStackItem() { pDraw->SetZoom(*this); }
|
||||
};
|
||||
|
||||
bool DDrawInit(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, int iBitDepth, unsigned int iMonitor);
|
||||
bool DDrawInit(C4AbstractApp * pApp, unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor);
|
||||
#endif // INC_STDDDRAW2
|
||||
|
|
|
@ -107,7 +107,6 @@ CStdGL::CStdGL():
|
|||
{
|
||||
GenericVBOs[0] = 0;
|
||||
Default();
|
||||
byByteCnt=4;
|
||||
// global ptr
|
||||
pGL = this;
|
||||
lines_tex = 0;
|
||||
|
@ -346,7 +345,7 @@ CStdGLCtx *CStdGL::CreateContext(C4Window * pWindow, C4AbstractApp *pApp)
|
|||
return pCtx;
|
||||
}
|
||||
|
||||
bool CStdGL::CreatePrimarySurfaces(unsigned int, unsigned int, int iColorDepth, unsigned int)
|
||||
bool CStdGL::CreatePrimarySurfaces(unsigned int, unsigned int, unsigned int)
|
||||
{
|
||||
// store options
|
||||
bool ok = RestoreDeviceObjects();
|
||||
|
@ -763,8 +762,8 @@ bool CStdGL::RestoreDeviceObjects()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
const char * linedata = byByteCnt == 2 ? "\xff\xf0\xff\xff" : "\xff\xff\xff\x00\xff\xff\xff\xff";
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 2, 0, GL_BGRA, byByteCnt == 2 ? GL_UNSIGNED_SHORT_4_4_4_4_REV : GL_UNSIGNED_INT_8_8_8_8_REV, linedata);
|
||||
static const char * linedata = "\xff\xff\xff\x00\xff\xff\xff\xff";
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 2, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, linedata);
|
||||
|
||||
MaxTexSize = 64;
|
||||
GLint s = 0;
|
||||
|
@ -906,7 +905,6 @@ void CStdGL::Default()
|
|||
pCurrCtx = NULL;
|
||||
iPixelFormat=0;
|
||||
sfcFmt=0;
|
||||
iClrDpt=0;
|
||||
Workarounds.LowMaxVertexUniformCount = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,6 @@ protected:
|
|||
GLenum sfcFmt; // texture surface format
|
||||
CStdGLCtx * pMainCtx; // main GL context
|
||||
CStdGLCtx *pCurrCtx; // current context (owned if fullscreen)
|
||||
int iClrDpt; // color depth
|
||||
// texture for smooth lines
|
||||
GLuint lines_tex;
|
||||
|
||||
|
@ -262,7 +261,7 @@ public:
|
|||
} Workarounds;
|
||||
|
||||
protected:
|
||||
bool CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor);
|
||||
bool CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor);
|
||||
|
||||
bool CheckGLError(const char *szAtOp);
|
||||
const char* GLErrorString(GLenum code);
|
||||
|
|
|
@ -207,7 +207,7 @@ bool CStdGLCtx::InitGlew(HINSTANCE hInst)
|
|||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DRAW_TO_WINDOW ;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = pGL->iClrDpt;
|
||||
pfd.cColorBits = C4Draw::COLOR_DEPTH;
|
||||
pfd.cDepthBits = 0;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
int temp_fmt = ChoosePixelFormat(dc, &pfd);
|
||||
|
|
|
@ -22,11 +22,9 @@ CStdNoGfx::CStdNoGfx()
|
|||
Default();
|
||||
}
|
||||
|
||||
bool CStdNoGfx::CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, int iColorDepth, unsigned int iMonitor)
|
||||
bool CStdNoGfx::CreatePrimarySurfaces(unsigned int iXRes, unsigned int iYRes, unsigned int iMonitor)
|
||||
{
|
||||
Log("Graphics disabled.");
|
||||
// Save back color depth
|
||||
byByteCnt = iColorDepth / 8;
|
||||
MaxTexSize = 2147483647;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual bool InvalidateDeviceObjects() { return true; }
|
||||
virtual bool DeleteDeviceObjects() { return true; }
|
||||
virtual bool DeviceReady() { return true; }
|
||||
virtual bool CreatePrimarySurfaces(unsigned int, unsigned int, int, unsigned int);
|
||||
virtual bool CreatePrimarySurfaces(unsigned int, unsigned int, unsigned int);
|
||||
virtual bool SetOutputAdapter(unsigned int) { return true; }
|
||||
|
||||
virtual void PerformMultiPix(C4Surface *, const C4BltVertex *, unsigned int, C4ShaderCall*) {}
|
||||
|
|
|
@ -126,7 +126,6 @@ void C4Surface::MoveFrom(C4Surface *psfcFrom)
|
|||
ClrByOwnerClr=psfcFrom->ClrByOwnerClr;
|
||||
iTexSize=psfcFrom->iTexSize;
|
||||
iTexX=psfcFrom->iTexX; iTexY=psfcFrom->iTexY;
|
||||
byBytesPP=psfcFrom->byBytesPP;
|
||||
#ifndef USE_CONSOLE
|
||||
Format=psfcFrom->Format;
|
||||
#endif
|
||||
|
@ -185,7 +184,6 @@ bool C4Surface::Create(int iWdt, int iHgt, int iFlags)
|
|||
#ifndef USE_CONSOLE
|
||||
Format=pGL->sfcFmt;
|
||||
#endif
|
||||
byBytesPP=pDraw->byByteCnt;
|
||||
// create textures
|
||||
if (!CreateTextures(iFlags)) { Clear(); return false; }
|
||||
// update clipping
|
||||
|
@ -606,18 +604,8 @@ DWORD C4Surface::GetPixDw(int iX, int iY, bool fApplyModulation)
|
|||
}
|
||||
// get pix of surface
|
||||
DWORD dwPix;
|
||||
if (byBytesPP == 4)
|
||||
{
|
||||
// 32 bit
|
||||
DWORD *pPix=(DWORD *) (pBuf+iY*iPitch+iX*4);
|
||||
dwPix = *pPix;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 16 bit
|
||||
WORD *pPix=(WORD *) (pBuf+iY*iPitch+iX*2);
|
||||
dwPix = ClrW2Dw(*pPix);
|
||||
}
|
||||
DWORD *pPix=(DWORD *) (pBuf+iY*iPitch+iX*4);
|
||||
dwPix = *pPix;
|
||||
// this is a ColorByOwner-surface?
|
||||
if (pMainSfc)
|
||||
{
|
||||
|
@ -693,17 +681,7 @@ bool C4Surface::SetPixDw(int iX, int iY, DWORD dwClr)
|
|||
if (!pTexRef->texLock.pBits)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, pTexRef->texName);
|
||||
if (byBytesPP == 4)
|
||||
{
|
||||
// 32 Bit
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, iX, iY, 1, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &dwClr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 16 bit
|
||||
uint16_t wClr=ClrDw2W(dwClr);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, iX, iY, 1, 1, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, &wClr);
|
||||
}
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, iX, iY, 1, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &dwClr);
|
||||
const bool fMipMap = (pTexRef->iFlags & C4SF_MipMap) != 0;
|
||||
if (fMipMap) glGenerateMipmap(GL_TEXTURE_2D);
|
||||
return true;
|
||||
|
@ -723,16 +701,7 @@ bool C4Surface::SetPixDw(int iX, int iY, DWORD dwClr)
|
|||
if (!GetLockTexAt(&pTexRef, iX, iY)) return false;
|
||||
}
|
||||
// ...and set in actual surface
|
||||
if (byBytesPP == 4)
|
||||
{
|
||||
// 32 bit
|
||||
pTexRef->SetPix4(iX, iY, dwClr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 16 bit
|
||||
pTexRef->SetPix2(iX, iY, ClrDw2W(dwClr));
|
||||
}
|
||||
pTexRef->SetPix(iX, iY, dwClr);
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
@ -746,66 +715,31 @@ bool C4Surface::SetPixAlpha(int iX, int iY, BYTE byAlpha)
|
|||
C4TexRef *pTexRef;
|
||||
if (!GetLockTexAt(&pTexRef, iX, iY)) return false;
|
||||
// set alpha value of pix in surface
|
||||
if (byBytesPP == 4)
|
||||
// 32 bit
|
||||
*(((BYTE *) pTexRef->texLock.pBits)+iY*pTexRef->texLock.Pitch+iX*4+3)=byAlpha;
|
||||
else
|
||||
{
|
||||
// 16 bit
|
||||
BYTE *pPix=((BYTE *) pTexRef->texLock.pBits)+iY*pTexRef->texLock.Pitch+iX*2+1;
|
||||
*pPix = (*pPix & 0x0f) | (byAlpha & 0xf0);
|
||||
}
|
||||
*(((BYTE *) pTexRef->texLock.pBits)+iY*pTexRef->texLock.Pitch+iX*4+3)=byAlpha;
|
||||
// success
|
||||
return true;
|
||||
}
|
||||
|
||||
bool C4Surface::BltPix(int iX, int iY, C4Surface *sfcSource, int iSrcX, int iSrcY, bool fTransparency)
|
||||
{
|
||||
// 16- or 32bit-blit. lock target
|
||||
// 32bit-blit. lock target
|
||||
C4TexRef *pTexRef;
|
||||
if (!GetLockTexAt(&pTexRef, iX, iY)) return false;
|
||||
if (byBytesPP == 4)
|
||||
DWORD *pPix32=(DWORD *) (((BYTE *) pTexRef->texLock.pBits)+iY*pTexRef->texLock.Pitch+iX*4);
|
||||
// get source pix as dword
|
||||
DWORD srcPix=sfcSource->GetPixDw(iSrcX, iSrcY, true);
|
||||
// merge
|
||||
if (!fTransparency)
|
||||
{
|
||||
// 32 bit
|
||||
DWORD *pPix32=(DWORD *) (((BYTE *) pTexRef->texLock.pBits)+iY*pTexRef->texLock.Pitch+iX*4);
|
||||
// get source pix as dword
|
||||
DWORD srcPix=sfcSource->GetPixDw(iSrcX, iSrcY, true);
|
||||
// merge
|
||||
if (!fTransparency)
|
||||
{
|
||||
// set it
|
||||
*pPix32=srcPix;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pDraw->dwBlitMode & C4GFXBLIT_ADDITIVE)
|
||||
BltAlphaAdd(*pPix32, srcPix);
|
||||
else
|
||||
BltAlpha(*pPix32, srcPix);
|
||||
}
|
||||
// set it
|
||||
*pPix32=srcPix;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 16 bit
|
||||
WORD *pPix16=(WORD *) (((BYTE *) pTexRef->texLock.pBits)+iY*pTexRef->texLock.Pitch+iX*2);
|
||||
// get source pix as dword
|
||||
DWORD srcPix=sfcSource->GetPixDw(iSrcX, iSrcY, true);
|
||||
if (!fTransparency)
|
||||
{
|
||||
// set it
|
||||
*pPix16=ClrDw2W(srcPix);
|
||||
}
|
||||
if (pDraw->dwBlitMode & C4GFXBLIT_ADDITIVE)
|
||||
BltAlphaAdd(*pPix32, srcPix);
|
||||
else
|
||||
{
|
||||
// merge in 32 bit
|
||||
DWORD dwDst=ClrW2Dw(*pPix16);
|
||||
if (pDraw->dwBlitMode & C4GFXBLIT_ADDITIVE)
|
||||
BltAlphaAdd(dwDst, srcPix);
|
||||
else
|
||||
BltAlpha(dwDst, srcPix);
|
||||
// set
|
||||
*pPix16=ClrDw2W(dwDst);
|
||||
}
|
||||
BltAlpha(*pPix32, srcPix);
|
||||
}
|
||||
// done
|
||||
return true;
|
||||
|
@ -860,7 +794,7 @@ bool C4Surface::CopyBytes(BYTE *pImageData)
|
|||
{
|
||||
// copy image data directly into textures
|
||||
auto pTex = textures.begin();
|
||||
int iSrcPitch = Wdt * byBytesPP; int iLineTotal = 0;
|
||||
int iSrcPitch = Wdt * C4Draw::COLOR_DEPTH_BYTES; int iLineTotal = 0;
|
||||
for (int iY=0; iY<iTexY; ++iY)
|
||||
{
|
||||
BYTE *pSource = pImageData + iSrcPitch * iLineTotal;
|
||||
|
@ -870,14 +804,14 @@ bool C4Surface::CopyBytes(BYTE *pImageData)
|
|||
++pTex;
|
||||
if (!pTex->Lock()) return false;
|
||||
BYTE *pTarget = (BYTE*)pTex->texLock.pBits;
|
||||
int iCpyNum = std::min(pTex->iSizeX, Wdt-iXImgPos)*byBytesPP;
|
||||
int iCpyNum = std::min(pTex->iSizeX, Wdt-iXImgPos) * C4Draw::COLOR_DEPTH_BYTES;
|
||||
int iYMax = std::min(pTex->iSizeY, Hgt-iLineTotal);
|
||||
for (int iLine = 0; iLine < iYMax; ++iLine)
|
||||
{
|
||||
memcpy(pTarget, pSource, iCpyNum);
|
||||
pSource += iSrcPitch;
|
||||
// FIXME: use pTex->texLock.Pitch here?
|
||||
pTarget += pTex->iSizeX*byBytesPP;
|
||||
pTarget += pTex->iSizeX * C4Draw::COLOR_DEPTH_BYTES;
|
||||
}
|
||||
pSource += iCpyNum - iSrcPitch*iYMax;
|
||||
iXImgPos += pTex->iSizeX;
|
||||
|
@ -910,8 +844,8 @@ C4TexRef::C4TexRef(int iSizeX, int iSizeY, int iFlags)
|
|||
|
||||
if ((iFlags & C4SF_Unlocked) == 0 && pDraw)
|
||||
{
|
||||
texLock.pBits = new unsigned char[iSizeX*iSizeY*pDraw->byByteCnt];
|
||||
texLock.Pitch = iSizeX*pDraw->byByteCnt;
|
||||
texLock.pBits = new unsigned char[iSizeX * iSizeY * C4Draw::COLOR_DEPTH_BYTES];
|
||||
texLock.Pitch = iSizeX * C4Draw::COLOR_DEPTH_BYTES;
|
||||
memset(texLock.pBits, 0x00, texLock.Pitch*iSizeY);
|
||||
// Always locked
|
||||
LockSize.x = LockSize.y = 0;
|
||||
|
@ -945,7 +879,7 @@ void C4TexRef::CreateTexture()
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, fTileable ? GL_REPEAT : GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, fMipMap ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iSizeX, iSizeY, 0, GL_BGRA, pDraw->byByteCnt == 2 ? GL_UNSIGNED_SHORT_4_4_4_4_REV : GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, iSizeX, iSizeY, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
if (fMipMap) glGenerateMipmap(GL_TEXTURE_2D);
|
||||
#endif
|
||||
}
|
||||
|
@ -969,8 +903,8 @@ bool C4TexRef::LockForUpdate(C4Rect & rtUpdate)
|
|||
// lock
|
||||
#ifndef USE_CONSOLE
|
||||
// prepare texture data
|
||||
texLock.pBits = new unsigned char[rtUpdate.Wdt * rtUpdate.Hgt * pGL->byByteCnt];
|
||||
texLock.Pitch = rtUpdate.Wdt * pGL->byByteCnt;
|
||||
texLock.pBits = new unsigned char[rtUpdate.Wdt * rtUpdate.Hgt * C4Draw::COLOR_DEPTH_BYTES];
|
||||
texLock.Pitch = rtUpdate.Wdt * C4Draw::COLOR_DEPTH_BYTES;
|
||||
LockSize = rtUpdate;
|
||||
return true;
|
||||
#endif
|
||||
|
@ -990,10 +924,10 @@ bool C4TexRef::Lock()
|
|||
{
|
||||
if (!pGL->pCurrCtx) return false;
|
||||
// get texture
|
||||
texLock.pBits = new unsigned char[iSizeX*iSizeY*pGL->byByteCnt];
|
||||
texLock.Pitch = iSizeX * pGL->byByteCnt;
|
||||
texLock.pBits = new unsigned char[iSizeX * iSizeY * C4Draw::COLOR_DEPTH_BYTES];
|
||||
texLock.Pitch = iSizeX * C4Draw::COLOR_DEPTH_BYTES;
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, pDraw->byByteCnt == 2 ? GL_UNSIGNED_SHORT_4_4_4_4_REV : GL_UNSIGNED_INT_8_8_8_8_REV, texLock.pBits);
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, texLock.pBits);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -1025,7 +959,7 @@ void C4TexRef::Unlock()
|
|||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
LockSize.x, LockSize.y, LockSize.Wdt, LockSize.Hgt,
|
||||
GL_BGRA, pDraw->byByteCnt == 2 ? GL_UNSIGNED_SHORT_4_4_4_4_REV : GL_UNSIGNED_INT_8_8_8_8_REV, texLock.pBits);
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, texLock.pBits);
|
||||
|
||||
delete[] static_cast<unsigned char*>(texLock.pBits); texLock.pBits=NULL;
|
||||
if (fMipMap) glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
@ -1038,22 +972,10 @@ bool C4TexRef::ClearRect(C4Rect &rtClear)
|
|||
if (!LockForUpdate(rtClear)) return false;
|
||||
// clear pixels
|
||||
int y;
|
||||
switch (pDraw->byByteCnt)
|
||||
for (y = rtClear.y; y < rtClear.y + rtClear.Hgt; ++y)
|
||||
{
|
||||
case 2:
|
||||
for (y = rtClear.y; y < rtClear.y + rtClear.Hgt; ++y)
|
||||
{
|
||||
for (int x = rtClear.x; x < rtClear.x + rtClear.Wdt; ++x)
|
||||
SetPix2(x, y, 0x0000);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (y = rtClear.y; y < rtClear.y + rtClear.Hgt; ++y)
|
||||
{
|
||||
for (int x = rtClear.x; x < rtClear.x + rtClear.Wdt; ++x)
|
||||
SetPix4(x, y, 0x00000000);
|
||||
}
|
||||
break;
|
||||
for (int x = rtClear.x; x < rtClear.x + rtClear.Wdt; ++x)
|
||||
SetPix(x, y, 0x00000000);
|
||||
}
|
||||
// success
|
||||
return true;
|
||||
|
@ -1065,22 +987,10 @@ bool C4TexRef::FillBlack()
|
|||
if (!Lock()) return false;
|
||||
// clear pixels
|
||||
int y;
|
||||
switch (pDraw->byByteCnt)
|
||||
for (y=0; y<iSizeY; ++y)
|
||||
{
|
||||
case 2:
|
||||
for (y=0; y<iSizeY; ++y)
|
||||
{
|
||||
for (int x = 0; x < iSizeX; ++x)
|
||||
SetPix2(x, y, 0xf000);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (y=0; y<iSizeY; ++y)
|
||||
{
|
||||
for (int x = 0; x < iSizeX; ++x)
|
||||
SetPix4(x, y, 0xff000000);
|
||||
}
|
||||
break;
|
||||
for (int x = 0; x < iSizeX; ++x)
|
||||
SetPix(x, y, 0xff000000);
|
||||
}
|
||||
// success
|
||||
return true;
|
||||
|
|
|
@ -79,7 +79,6 @@ public:
|
|||
CStdGLCtx * pCtx;
|
||||
#endif
|
||||
std::vector<C4TexRef> textures; // textures
|
||||
BYTE byBytesPP; // bytes per pixel (2 or 4)
|
||||
C4Surface *pMainSfc; // main surface for simple ColorByOwner-surfaces
|
||||
C4Surface *pNormalSfc; // normal map; can be NULL
|
||||
DWORD ClrByOwnerClr; // current color to be used for ColorByOwner-blits
|
||||
|
@ -193,11 +192,7 @@ public:
|
|||
void Unlock(); // unlock texture
|
||||
bool ClearRect(C4Rect &rtClear); // clear rect in texture to transparent
|
||||
bool FillBlack(); // fill complete texture in black
|
||||
void SetPix2(int iX, int iY, WORD v)
|
||||
{
|
||||
*((WORD *) (((BYTE *) texLock.pBits) + (iY - LockSize.y) * texLock.Pitch + (iX - LockSize.x) * 2)) = v;
|
||||
}
|
||||
void SetPix4(int iX, int iY, DWORD v)
|
||||
void SetPix(int iX, int iY, DWORD v)
|
||||
{
|
||||
*((DWORD *) (((BYTE *) texLock.pBits) + (iY - LockSize.y) * texLock.Pitch + (iX - LockSize.x) * 4)) = v;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ bool C4Surface::ReadPNG(CStdStream &hGroup, int iFlags)
|
|||
// The global, not texture-relative position
|
||||
int rY = iY + tY * iTexSize;
|
||||
#ifndef __BIG_ENDIAN__
|
||||
if (byBytesPP == 4 && png.iClrType == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
if (png.iClrType == PNG_COLOR_TYPE_RGB_ALPHA)
|
||||
{
|
||||
// Optimize the easy case of a png in the same format as the display
|
||||
// 32 bit
|
||||
|
@ -203,16 +203,8 @@ bool C4Surface::ReadPNG(CStdStream &hGroup, int iFlags)
|
|||
// if color is fully transparent, ensure it's black
|
||||
if (dwCol>>24 == 0x00) dwCol=0x00000000;
|
||||
// set pix in surface
|
||||
if (byBytesPP == 4)
|
||||
{
|
||||
DWORD *pPix=(DWORD *) (((char *) pTexRef->texLock.pBits) + iY * pTexRef->texLock.Pitch + iX * 4);
|
||||
*pPix=dwCol;
|
||||
}
|
||||
else
|
||||
{
|
||||
WORD *pPix=(WORD *) (((char *) pTexRef->texLock.pBits) + iY * pTexRef->texLock.Pitch + iX * 2);
|
||||
*pPix=ClrDw2W(dwCol);
|
||||
}
|
||||
DWORD *pPix=(DWORD *) (((char *) pTexRef->texLock.pBits) + iY * pTexRef->texLock.Pitch + iX * 4);
|
||||
*pPix=dwCol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include <C4windowswrapper.h>
|
||||
#include <C4GfxErrorDlg.h>
|
||||
|
||||
#include "graphics/C4Draw.h"
|
||||
|
||||
static int edittext_toi(HWND hWnd, int field)
|
||||
{
|
||||
WCHAR buf[512]; buf[511] = 0;
|
||||
|
@ -85,7 +87,7 @@ static INT_PTR CALLBACK GfxErrProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPAR
|
|||
bool found = false;
|
||||
int32_t idx = 0, iXRes, iYRes, iBitDepth;
|
||||
while (Application.GetIndexedDisplayMode(idx++, &iXRes, &iYRes, &iBitDepth, NULL, Config.Graphics.Monitor))
|
||||
if (iBitDepth == Config.Graphics.BitDepth)
|
||||
if (iBitDepth == C4Draw::COLOR_DEPTH)
|
||||
if(iXRes == resx && iYRes == resy)
|
||||
{
|
||||
found = true;
|
||||
|
|
|
@ -803,19 +803,6 @@ C4StartupOptionsDlg::C4StartupOptionsDlg() : C4StartupDlg(LoadResStrNoAmp("IDS_D
|
|||
pGfxResCombo->SetDecoration(&(C4Startup::Get()->Graphics.fctContext));
|
||||
pGfxResCombo->SetText(GetGfxResString(Config.Graphics.ResX, Config.Graphics.ResY).getData());
|
||||
pGroupResolution->AddElement(pGfxResCombo);
|
||||
// color depth checkboxes
|
||||
C4GUI::ComponentAligner cdBox(caGroupResolution.GetGridCell(0,1,iOpt++,iNumGfxOptions), 0, 0, false);
|
||||
w=20; q=12; pUseFont->GetTextExtent(LoadResStr("IDS_CTL_BITDEPTH"), w,q, true);
|
||||
pGroupResolution->AddElement(new C4GUI::Label(LoadResStr("IDS_CTL_BITDEPTH"), cdBox.GetFromLeft(w+C4GUI_DefDlgSmallIndent,q), ALeft, C4StartupFontClr, pUseFont, false, false));
|
||||
pUseFont->GetTextExtent("32bit", w,q,true); w = std::min<int32_t>(caGroupResolution.GetInnerWidth(), w+40);
|
||||
C4GUI::ComboBox *pGfxClrDepthCombo = new C4GUI::ComboBox(cdBox.GetFromLeft(w+40,C4GUI::ComboBox::GetDefaultHeight()));
|
||||
pGfxClrDepthCombo->SetToolTip(LoadResStr("IDS_CTL_BITDEPTHC"));
|
||||
pGfxClrDepthCombo->SetComboCB(new C4GUI::ComboBox_FillCallback<C4StartupOptionsDlg>(this, &C4StartupOptionsDlg::OnGfxClrDepthComboFill, &C4StartupOptionsDlg::OnGfxClrDepthComboSelChange));
|
||||
pGfxClrDepthCombo->SetColors(C4StartupFontClr, C4StartupEditBGColor, C4StartupEditBorderColor);
|
||||
pGfxClrDepthCombo->SetFont(pUseFont);
|
||||
pGfxClrDepthCombo->SetDecoration(&(C4Startup::Get()->Graphics.fctContext));
|
||||
pGfxClrDepthCombo->SetText(FormatString("%d Bit", (int)Config.Graphics.BitDepth).getData());
|
||||
pGroupResolution->AddElement(pGfxClrDepthCombo);
|
||||
// fullscreen combobox
|
||||
C4GUI::ComponentAligner fsBox(caGroupResolution.GetGridCell(0,1,iOpt++,iNumGfxOptions), 0, 0, false);
|
||||
w=20; q=12; pUseFont->GetTextExtent(LoadResStr("IDS_CTL_FULLSCREENMODE"), w,q, true);
|
||||
|
@ -1085,7 +1072,7 @@ void C4StartupOptionsDlg::OnGfxResComboFill(C4GUI::ComboBox_FillCB *pFiller)
|
|||
int32_t idx = 0, iXRes, iYRes, iBitDepth;
|
||||
while (Application.GetIndexedDisplayMode(idx++, &iXRes, &iYRes, &iBitDepth, NULL, Config.Graphics.Monitor))
|
||||
#ifdef _WIN32 // why only WIN32?
|
||||
if (iBitDepth == Config.Graphics.BitDepth)
|
||||
if (iBitDepth == C4Draw::COLOR_DEPTH)
|
||||
#endif
|
||||
{
|
||||
StdStrBuf sGfxString = GetGfxResString(iXRes, iYRes);
|
||||
|
@ -1124,7 +1111,7 @@ bool C4StartupOptionsDlg::TryNewResolution(int32_t iResX, int32_t iResY)
|
|||
else if (iResY > 800)
|
||||
iNewFontSize = 16;
|
||||
// call application to set it
|
||||
if (!Application.SetVideoMode(iResX, iResY, Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, true))
|
||||
if (!Application.SetVideoMode(iResX, iResY, Config.Graphics.RefreshRate, Config.Graphics.Monitor, true))
|
||||
{
|
||||
StdCopyStrBuf strChRes(LoadResStr("IDS_MNU_SWITCHRESOLUTION"));
|
||||
pScreen->ShowMessage(FormatString(LoadResStr("IDS_ERR_SWITCHRES"), Application.GetLastError()).getData(), strChRes.getData(), C4GUI::Ico_Clonk, NULL);
|
||||
|
@ -1150,7 +1137,7 @@ bool C4StartupOptionsDlg::TryNewResolution(int32_t iResX, int32_t iResY)
|
|||
if (!pScreen->ShowModalDlg(pConfirmDlg, true))
|
||||
{
|
||||
// abort: Restore screen, if this was not some program abort
|
||||
if (Application.SetVideoMode(iOldResX, iOldResY, Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed))
|
||||
if (Application.SetVideoMode(iOldResX, iOldResY, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed))
|
||||
{
|
||||
if (iNewFontSize != iOldFontSize) Application.SetGameFont(Config.General.RXFontName, iOldFontSize);
|
||||
RecreateDialog(false);
|
||||
|
@ -1162,7 +1149,7 @@ bool C4StartupOptionsDlg::TryNewResolution(int32_t iResX, int32_t iResY)
|
|||
Config.Graphics.ResX = iResX;
|
||||
Config.Graphics.ResY = iResY;
|
||||
if(Config.Graphics.Windowed)
|
||||
Application.SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, false);
|
||||
Application.SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.RefreshRate, Config.Graphics.Monitor, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1174,26 +1161,6 @@ StdStrBuf C4StartupOptionsDlg::GetGfxResString(int32_t iResX, int32_t iResY)
|
|||
return FormatString("%d x %d", (int)iResX, (int)iResY);
|
||||
}
|
||||
|
||||
void C4StartupOptionsDlg::OnGfxClrDepthComboFill(C4GUI::ComboBox_FillCB *pFiller)
|
||||
{
|
||||
pFiller->ClearEntries();
|
||||
for (int32_t iBitDepthIdx = 0; iBitDepthIdx<2; ++iBitDepthIdx)
|
||||
{
|
||||
int iBitDepth = (iBitDepthIdx+1) * 16;
|
||||
pFiller->AddEntry(FormatString("%d Bit", (int)iBitDepth).getData(), iBitDepthIdx);
|
||||
}
|
||||
}
|
||||
|
||||
bool C4StartupOptionsDlg::OnGfxClrDepthComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection)
|
||||
{
|
||||
// change config
|
||||
Config.Graphics.BitDepth = (idNewSelection+1) * 16;
|
||||
// notify user that he has to restart to see any changes
|
||||
StdStrBuf sTitle; sTitle.Copy(LoadResStrNoAmp("IDS_CTL_BITDEPTH"));
|
||||
GetScreen()->ShowMessage(LoadResStr("IDS_MSG_RESTARTCHANGECFG"), sTitle.getData(), C4GUI::Ico_Notify, &Config.Startup.HideMsgGfxBitDepthChange);
|
||||
return true;
|
||||
}
|
||||
|
||||
const char * C4StartupOptionsDlg::GetWindowedName(int32_t mode /* = -1*/)
|
||||
{
|
||||
if(mode == -1)
|
||||
|
@ -1215,7 +1182,7 @@ void C4StartupOptionsDlg::OnWindowedModeComboFill(C4GUI::ComboBox_FillCB *pFille
|
|||
bool C4StartupOptionsDlg::OnWindowedModeComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection)
|
||||
{
|
||||
Config.Graphics.Windowed = idNewSelection;
|
||||
Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed);
|
||||
Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed);
|
||||
pForCombo->SetText(GetWindowedName(idNewSelection));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -128,8 +128,6 @@ private:
|
|||
bool OnWindowedModeComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection);
|
||||
void OnGfxResComboFill(C4GUI::ComboBox_FillCB *pFiller);
|
||||
bool OnGfxResComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection);
|
||||
void OnGfxClrDepthComboFill(C4GUI::ComboBox_FillCB *pFiller);
|
||||
bool OnGfxClrDepthComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection);
|
||||
void OnGfxMSComboFill(C4GUI::ComboBox_FillCB *pFiller);
|
||||
bool OnGfxMSComboSelChange(C4GUI::ComboBox *pForCombo, int32_t idNewSelection);
|
||||
bool TryNewResolution(int32_t iResX, int32_t iResY);
|
||||
|
|
|
@ -229,8 +229,7 @@ bool C4LandscapeRenderGL::InitMaterialTexture(C4TextureMap *pTexs)
|
|||
iMaterialHeight = iTexHgt;
|
||||
|
||||
// Compose together data of all textures
|
||||
const int iBytesPP = pRefSfc->byBytesPP;
|
||||
const int iTexSize = iTexWdt * iTexHgt * iBytesPP;
|
||||
const int iTexSize = iTexWdt * iTexHgt * C4Draw::COLOR_DEPTH_BYTES;
|
||||
const int iSize = iTexSize * iMaterialTextureDepth;
|
||||
BYTE *pData = new BYTE [iSize];
|
||||
for(int i = 0; i < iMaterialTextureDepth; i++)
|
||||
|
@ -321,13 +320,13 @@ bool C4LandscapeRenderGL::InitMaterialTexture(C4TextureMap *pTexs)
|
|||
|
||||
// Make it happen!
|
||||
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, iTexWdt, iTexHgt, iMaterialTextureDepth, 0, GL_BGRA,
|
||||
iBytesPP == 2 ? GL_UNSIGNED_SHORT_4_4_4_4_REV : GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
GL_UNSIGNED_INT_8_8_8_8_REV,
|
||||
pData);
|
||||
|
||||
glGenerateMipmap(GL_TEXTURE_2D_ARRAY);
|
||||
|
||||
// Statistics
|
||||
iSizeSum += iTexWdt * iTexHgt * iMaterialTextureDepth * iBytesPP;
|
||||
iSizeSum += iTexWdt * iTexHgt * iMaterialTextureDepth * C4Draw::COLOR_DEPTH_BYTES;
|
||||
|
||||
// Dispose of data
|
||||
delete [] pData;
|
||||
|
@ -455,7 +454,7 @@ void C4LandscapeRenderGL::Update(C4Rect To, C4Landscape *pSource)
|
|||
data[C4LR_Place] = placement;
|
||||
|
||||
for(int i = 0; i < C4LR_SurfaceCount; i++)
|
||||
texture[i]->SetPix4(To.x+x, To.y+y,
|
||||
texture[i]->SetPix(To.x+x, To.y+y,
|
||||
RGBA(data[i*4+0], data[i*4+1], data[i*4+2], data[i*4+3]));
|
||||
|
||||
// Update sums (last column would be out-of-bounds, and not
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
virtual void Quit();
|
||||
|
||||
bool GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32_t *piYRes, int32_t *piBitDepth, int32_t *piRefreshRate, uint32_t iMonitor);
|
||||
bool SetVideoMode(int iXRes, int iYRes, unsigned int iColorDepth, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen);
|
||||
bool SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen);
|
||||
void RestoreVideoMode();
|
||||
|
||||
virtual bool DoScheduleProcs(int iTimeout);
|
||||
|
|
|
@ -129,7 +129,7 @@ bool C4AbstractApp::FlushMessages()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iColorDepth, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default());
|
||||
|
|
|
@ -152,7 +152,7 @@ void C4AbstractApp::RestoreVideoMode()
|
|||
{
|
||||
}
|
||||
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iColorDepth, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
{
|
||||
fFullScreen &= !lionAndBeyond(); // Always false for Lion since then Lion's true(tm) Fullscreen is used
|
||||
C4WindowController* controller = pWindow->objectiveCObject<C4WindowController>();
|
||||
|
|
|
@ -169,7 +169,7 @@ void C4AbstractApp::HandleSDLEvent(SDL_Event& e)
|
|||
if (e.key.keysym.sym == SDLK_f && (e.key.keysym.mod & (KMOD_LMETA | KMOD_RMETA)))
|
||||
{
|
||||
Config.Graphics.Windowed = !Config.Graphics.Windowed;
|
||||
Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed);
|
||||
Application.SetVideoMode(Config.Graphics.ResX, Config.Graphics.ResY, Config.Graphics.RefreshRate, Config.Graphics.Monitor, !Config.Graphics.Windowed);
|
||||
pDraw->InvalidateDeviceObjects();
|
||||
pDraw->RestoreDeviceObjects();
|
||||
|
||||
|
@ -249,13 +249,13 @@ bool C4AbstractApp::GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32
|
|||
return true;
|
||||
}
|
||||
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iColorDepth, unsigned int RefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int RefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
{
|
||||
//RECT r;
|
||||
//pWindow->GetSize(&r);
|
||||
// FIXME: optimize redundant calls away. maybe make all platforms implicitely call SetVideoMode in C4Window::Init?
|
||||
// SDL doesn't support multiple monitors.
|
||||
if (!SDL_SetVideoMode(iXRes == -1 ? 0 : iXRes, iYRes == -1 ? 0 : iYRes, iColorDepth,
|
||||
if (!SDL_SetVideoMode(iXRes == -1 ? 0 : iXRes, iYRes == -1 ? 0 : iYRes, C4Draw::COLOR_DEPTH,
|
||||
SDL_OPENGL | (fFullScreen ? SDL_FULLSCREEN : 0)))
|
||||
{
|
||||
sLastError.Copy(SDL_GetError());
|
||||
|
|
|
@ -65,7 +65,7 @@ bool C4AbstractApp::GetIndexedDisplayMode(int32_t iIndex, int32_t *piXRes, int32
|
|||
|
||||
void C4AbstractApp::RestoreVideoMode() {}
|
||||
|
||||
bool C4AbstractApp::SetVideoMode(int, int, unsigned int, unsigned int, unsigned int, bool)
|
||||
bool C4AbstractApp::SetVideoMode(int, int, unsigned int, unsigned int, bool)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ static bool fullscreen_needs_restore = false;
|
|||
static gboolean fullscreen_restore(gpointer data)
|
||||
{
|
||||
if (fullscreen_needs_restore)
|
||||
Application.SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, Application.FullScreenMode());
|
||||
Application.SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.RefreshRate, Config.Graphics.Monitor, Application.FullScreenMode());
|
||||
fullscreen_needs_restore = false;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ C4Window * C4Window::Init(WindowKind windowKind, C4AbstractApp * pApp, const cha
|
|||
// SDL doesn't support multiple monitors.
|
||||
if (!SDL_SetVideoMode(Application.GetConfigWidth() == -1 ? 0 : Application.GetConfigWidth(),
|
||||
Application.GetConfigHeight() == -1 ? 0 : Application.GetConfigHeight(),
|
||||
Config.Graphics.BitDepth, SDL_OPENGL | (Config.Graphics.Windowed ? 0 : SDL_FULLSCREEN)))
|
||||
C4Draw::COLOR_DEPTH, SDL_OPENGL | (Config.Graphics.Windowed ? 0 : SDL_FULLSCREEN)))
|
||||
{
|
||||
Log(SDL_GetError());
|
||||
return 0;
|
||||
|
|
|
@ -112,7 +112,7 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
|
|||
// restore textures
|
||||
if (Application.FullScreenMode())
|
||||
{
|
||||
Application.SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, true);
|
||||
Application.SetVideoMode(Application.GetConfigWidth(), Application.GetConfigHeight(), Config.Graphics.RefreshRate, Config.Graphics.Monitor, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -888,7 +888,7 @@ void C4AbstractApp::RestoreVideoMode()
|
|||
{
|
||||
}
|
||||
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iColorDepth, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iRefreshRate, unsigned int iMonitor, bool fFullScreen)
|
||||
{
|
||||
#ifndef USE_CONSOLE
|
||||
SetWindowLong(pWindow->hWindow, GWL_EXSTYLE,
|
||||
|
@ -950,7 +950,7 @@ bool C4AbstractApp::SetVideoMode(int iXRes, int iYRes, unsigned int iColorDepth,
|
|||
int i=0;
|
||||
if (!fFound) while (EnumDisplaySettingsW(Mon.GetWideChar(), i++, &dmode))
|
||||
// compare enumerated mode with requested settings
|
||||
if (static_cast<int>(dmode.dmPelsWidth) == iXRes && static_cast<int>(dmode.dmPelsHeight) == iYRes && dmode.dmBitsPerPel == iColorDepth && dmode.dmDisplayOrientation == orientation
|
||||
if (static_cast<int>(dmode.dmPelsWidth) == iXRes && static_cast<int>(dmode.dmPelsHeight) == iYRes && dmode.dmBitsPerPel == C4Draw::COLOR_DEPTH && dmode.dmDisplayOrientation == orientation
|
||||
&& (iRefreshRate == 0 || dmode.dmDisplayFrequency == iRefreshRate))
|
||||
{
|
||||
fFound=true;
|
||||
|
|
Loading…
Reference in New Issue