forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphicsDeviceManager.SDL.cs
49 lines (43 loc) · 2.18 KB
/
GraphicsDeviceManager.SDL.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using Microsoft.Xna.Framework.Graphics;
namespace Microsoft.Xna.Framework
{
public partial class GraphicsDeviceManager
{
partial void PlatformInitialize(PresentationParameters presentationParameters)
{
var surfaceFormat = _game.graphicsDeviceManager.PreferredBackBufferFormat.GetColorFormat();
var depthStencilFormat = _game.graphicsDeviceManager.PreferredDepthStencilFormat;
// TODO Need to get this data from the Presentation Parameters
Sdl.GL.SetAttribute(Sdl.GL.Attribute.RedSize, surfaceFormat.R);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.GreenSize, surfaceFormat.G);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.BlueSize, surfaceFormat.B);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.AlphaSize, surfaceFormat.A);
switch (depthStencilFormat)
{
case DepthFormat.None:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 0);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
break;
case DepthFormat.Depth16:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 16);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
break;
case DepthFormat.Depth24:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 24);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 0);
break;
case DepthFormat.Depth24Stencil8:
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DepthSize, 24);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.StencilSize, 8);
break;
}
Sdl.GL.SetAttribute(Sdl.GL.Attribute.DoubleBuffer, 1);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.ContextMajorVersion, 2);
Sdl.GL.SetAttribute(Sdl.GL.Attribute.ContextMinorVersion, 1);
((SdlGameWindow)SdlGameWindow.Instance).CreateWindow();
}
}
}