use display lists in opengl

This commit is contained in:
Alexander Eckart committed 2012-03-14 19:56:22 +01:00
1 parent 0ea6a9043b
commit a78b61bbe7
1 file changed
+37 -1
+37 -1
View File
@@ -40,13 +40,14 @@ namespace Vocaluxe.Lib.Draw
private bool _fullscreen = false; private bool _fullscreen = false;
private List<STexture> _Textures; private List<STexture> _Textures;
private List<int> _GLList;
private int h = 1; private int h = 1;
private int w = 1; private int w = 1;
private int y = 0; private int y = 0;
private int x = 0; private int x = 0;
private bool _UsePBO = false; private bool _UsePBO = true;
#endregion private vars #endregion private vars
@@ -55,6 +56,7 @@ namespace Vocaluxe.Lib.Draw
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon)); this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
_Textures = new List<STexture>(); _Textures = new List<STexture>();
_GLList = new List<int>();
//Check AA Mode //Check AA Mode
CConfig.AAMode = (EAntiAliasingModes)CheckAntiAliasingMode((int)CConfig.AAMode); CConfig.AAMode = (EAntiAliasingModes)CheckAntiAliasingMode((int)CConfig.AAMode);
@@ -440,6 +442,12 @@ namespace Vocaluxe.Lib.Draw
ClearScreen(); ClearScreen();
_Run = _Run && CGraphics.Draw(); _Run = _Run && CGraphics.Draw();
foreach (int list in _GLList)
{
GL.CallList(list);
}
_GLList.Clear();
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse); _Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
control.SwapBuffers(); control.SwapBuffers();
@@ -594,6 +602,11 @@ namespace Vocaluxe.Lib.Draw
} }
public void DrawColor(SColorF color, SRectF rect) public void DrawColor(SColorF color, SRectF rect)
{
int list = GL.GenLists(1);
_GLList.Add(list);
GL.NewList(list, ListMode.Compile);
{ {
GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.Blend);
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
@@ -607,6 +620,8 @@ namespace Vocaluxe.Lib.Draw
GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Blend);
} }
GL.EndList();
}
#endregion Basic Draw Methods #endregion Basic Draw Methods
@@ -1030,6 +1045,11 @@ namespace Vocaluxe.Lib.Draw
return; return;
if (_TextureExists(Texture)) if (_TextureExists(Texture))
{
int list = GL.GenLists(1);
_GLList.Add(list);
GL.NewList(list, ListMode.Compile);
{ {
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.index);
@@ -1123,11 +1143,18 @@ namespace Vocaluxe.Lib.Draw
GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Blend);
GL.BindTexture(TextureTarget.Texture2D, 0); GL.BindTexture(TextureTarget.Texture2D, 0);
} }
GL.EndList();
}
} }
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end) public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end)
{ {
if (_TextureExists(Texture)) if (_TextureExists(Texture))
{
int list = GL.GenLists(1);
_GLList.Add(list);
GL.NewList(list, ListMode.Compile);
{ {
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.index);
@@ -1155,6 +1182,8 @@ namespace Vocaluxe.Lib.Draw
GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Blend);
GL.BindTexture(TextureTarget.Texture2D, 0); GL.BindTexture(TextureTarget.Texture2D, 0);
} }
GL.EndList();
}
} }
public void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) public void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
@@ -1172,6 +1201,11 @@ namespace Vocaluxe.Lib.Draw
height = bounds.H; height = bounds.H;
if (_TextureExists(Texture)) if (_TextureExists(Texture))
{
int list = GL.GenLists(1);
_GLList.Add(list);
GL.NewList(list, ListMode.Compile);
{ {
GL.BindTexture(TextureTarget.Texture2D, Texture.index); GL.BindTexture(TextureTarget.Texture2D, Texture.index);
@@ -1249,6 +1283,8 @@ namespace Vocaluxe.Lib.Draw
GL.Disable(EnableCap.Blend); GL.Disable(EnableCap.Blend);
GL.BindTexture(TextureTarget.Texture2D, 0); GL.BindTexture(TextureTarget.Texture2D, 0);
} }
GL.EndList();
}
} }
public int TextureCount() public int TextureCount()