Some styling for Draw classes
This commit is contained in:
1 parent
5587a322be
commit
914f15f0ad
2 files changed
+68
-80
No files matched your search
@@ -246,40 +246,39 @@ namespace Vocaluxe.Lib.Draw
|
||||
// The window was minimized, so restore it to the last known size
|
||||
if (ClientSize.Width == 0 || ClientSize.Height == 0)
|
||||
ClientSize = _SizeBeforeMinimize;
|
||||
if (_Run)
|
||||
if (!_Run)
|
||||
return;
|
||||
_H = ClientSize.Height;
|
||||
_W = ClientSize.Width;
|
||||
_Y = 0;
|
||||
_X = 0;
|
||||
|
||||
if (_W / (float)_H > CSettings.GetRenderAspect())
|
||||
{
|
||||
_H = ClientSize.Height;
|
||||
_W = ClientSize.Width;
|
||||
_Y = 0;
|
||||
_X = 0;
|
||||
|
||||
if (_W / (float)_H > CSettings.GetRenderAspect())
|
||||
{
|
||||
//The windows's width is too big
|
||||
_W = (int)Math.Round(_H * CSettings.GetRenderAspect());
|
||||
_X = (ClientSize.Width - _W) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//The windows's height is too big
|
||||
_H = (int)Math.Round(_W / CSettings.GetRenderAspect());
|
||||
_Y = (ClientSize.Height - _H) / 2;
|
||||
}
|
||||
|
||||
//Apply the new sizes to the PresentParameters
|
||||
_PresentParameters.BackBufferWidth = ClientSize.Width;
|
||||
_PresentParameters.BackBufferHeight = ClientSize.Height;
|
||||
ClearScreen();
|
||||
//To set new PresentParameters the device has to be resetted
|
||||
_Reset();
|
||||
//All configurations got flushed due to Reset(), so apply them again
|
||||
Init();
|
||||
|
||||
//Set the new Viewport
|
||||
_Device.Viewport = new Viewport(_X, _Y, _W, _H);
|
||||
//Store size so it can get restored after the window gets minimized
|
||||
_SizeBeforeMinimize = ClientSize;
|
||||
//The windows's width is too big
|
||||
_W = (int)Math.Round(_H * CSettings.GetRenderAspect());
|
||||
_X = (ClientSize.Width - _W) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//The windows's height is too big
|
||||
_H = (int)Math.Round(_W / CSettings.GetRenderAspect());
|
||||
_Y = (ClientSize.Height - _H) / 2;
|
||||
}
|
||||
|
||||
//Apply the new sizes to the PresentParameters
|
||||
_PresentParameters.BackBufferWidth = ClientSize.Width;
|
||||
_PresentParameters.BackBufferHeight = ClientSize.Height;
|
||||
ClearScreen();
|
||||
//To set new PresentParameters the device has to be resetted
|
||||
_Reset();
|
||||
//All configurations got flushed due to Reset(), so apply them again
|
||||
Init();
|
||||
|
||||
//Set the new Viewport
|
||||
_Device.Viewport = new Viewport(_X, _Y, _W, _H);
|
||||
//Store size so it can get restored after the window gets minimized
|
||||
_SizeBeforeMinimize = ClientSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -441,32 +441,29 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
while (_Run)
|
||||
{
|
||||
ClearScreen();
|
||||
if (!CGraphics.Draw())
|
||||
_Run = false;
|
||||
if (!CGraphics.UpdateGameLogic(_Keys, _Mouse))
|
||||
_Run = false;
|
||||
|
||||
_Control.SwapBuffers();
|
||||
|
||||
if (CSettings.IsFullScreen != _Fullscreen)
|
||||
_ToggleFullScreen();
|
||||
|
||||
_CheckQueue();
|
||||
|
||||
if (CTime.IsRunning())
|
||||
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
|
||||
|
||||
if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
|
||||
Thread.Sleep(delay);
|
||||
|
||||
CTime.CalculateFPS();
|
||||
CTime.Restart();
|
||||
|
||||
Application.DoEvents();
|
||||
|
||||
if (_Run)
|
||||
{
|
||||
ClearScreen();
|
||||
if (!CGraphics.Draw())
|
||||
_Run = false;
|
||||
if (!CGraphics.UpdateGameLogic(_Keys, _Mouse))
|
||||
_Run = false;
|
||||
|
||||
_Control.SwapBuffers();
|
||||
|
||||
if ((CSettings.IsFullScreen && !_Fullscreen) || (!CSettings.IsFullScreen && _Fullscreen))
|
||||
_ToggleFullScreen();
|
||||
|
||||
_CheckQueue();
|
||||
|
||||
if (CTime.IsRunning())
|
||||
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
|
||||
|
||||
if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
|
||||
Thread.Sleep(delay);
|
||||
|
||||
CTime.CalculateFPS();
|
||||
CTime.Restart();
|
||||
}
|
||||
}
|
||||
Close();
|
||||
}
|
||||
@@ -505,11 +502,10 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
CTexture texture = _GetNewTexture(_W, _H);
|
||||
|
||||
int id = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, id);
|
||||
texture.ID = id;
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
texture.ID = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, _X, _Y, _W, _H);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
@@ -540,7 +536,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, texture.UsedWidth, texture.UsedHeight);
|
||||
GL.CopyTexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, 0, 0, GetScreenWidth(), GetScreenHeight());
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
@@ -715,9 +711,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
CTexture texture = new CTexture(bmp.Width, bmp.Height, w, h, true);
|
||||
|
||||
int id = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, id);
|
||||
texture.ID = id;
|
||||
texture.ID = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
Bitmap bmp2 = null;
|
||||
try
|
||||
{
|
||||
@@ -751,10 +746,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
|
||||
//GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
// Add to Texture List
|
||||
texture.TexturePath = String.Empty;
|
||||
|
||||
@@ -800,23 +794,18 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
}
|
||||
|
||||
int id = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, id);
|
||||
texture.ID = id;
|
||||
texture.ID = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
||||
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
|
||||
//GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
|
||||
@@ -857,6 +846,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, texture.ID);
|
||||
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
@@ -869,14 +859,13 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
||||
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
|
||||
GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
|
||||
//GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
|
||||
//GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
//GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user