TriEngine  v0.0.16
General-purpose engine in C#/OpenGL
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
TriDevs.TriEngine.GameWindow2D Class Referenceabstract

Game window class specialized for drawing 2D graphics. More...

Inheritance diagram for TriDevs.TriEngine.GameWindow2D:
[legend]
Collaboration diagram for TriDevs.TriEngine.GameWindow2D:
[legend]

Protected Member Functions

 GameWindow2D (int width, int height, string title, bool vsync=true)
 
override void OnResize (EventArgs e)
 
override void OnLoad (EventArgs e)
 
sealed override void OnRenderFrame (FrameEventArgs e)
 
abstract void OnDraw (FrameEventArgs e)
 
void Initialize ()
 

Properties

Color ClearColor [get, set]
 Gets or sets the clear color for this window. More...
 

Detailed Description

Game window class specialized for drawing 2D graphics.

Constructor & Destructor Documentation

TriDevs.TriEngine.GameWindow2D.GameWindow2D ( int  width,
int  height,
string  title,
bool  vsync = true 
)
protected
52  : base(width, height, GraphicsMode.Default, title)
53  {
54  VSync = vsync ? VSyncMode.On : VSyncMode.Off;
55 
56  ClearColor = Color.CornflowerBlue;
57  }

Member Function Documentation

void TriDevs.TriEngine.GameWindow2D.Initialize ( )
protected
95  {
96  try
97  {
98  GL.Viewport(0, 0, ClientRectangle.Width, ClientRectangle.Height);
99 
100  GL.MatrixMode(MatrixMode.Projection);
101 
102  GL.LoadIdentity();
103 
104  GL.Ortho(0, ClientRectangle.Width - 1, ClientRectangle.Height - 1, 0, -1, 1);
105 
106  GL.MatrixMode(MatrixMode.Modelview);
107 
108  // Disable the Z-buffer, this is a 2D game window
109  //GL.Disable(EnableCap.DepthTest);
110  //GL.Disable(EnableCap.CullFace);
111  GL.Enable(EnableCap.Blend);
112  GL.BlendEquation(BlendEquationMode.FuncAdd);
113  GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
114  //GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
115  //GL.RenderMode(RenderingMode.Render);
116 
117  GL.ClearColor(ClearColor.ToColor4());
118  }
119  catch (Exception ex)
120  {
121  Helpers.Exceptions.Throw(ex, "Initialization of 2D game window failed during OpenGL setup!");
122  }
123  }
abstract void TriDevs.TriEngine.GameWindow2D.OnDraw ( FrameEventArgs  e)
protectedpure virtual
override void TriDevs.TriEngine.GameWindow2D.OnLoad ( EventArgs  e)
protected
75  {
76  base.OnLoad(e);
77 
78  Initialize();
79  }
sealed override void TriDevs.TriEngine.GameWindow2D.OnRenderFrame ( FrameEventArgs  e)
protected
82  {
83  base.OnRenderFrame(e);
84 
85  GL.Clear(ClearBufferMask.ColorBufferBit);
86 
87  OnDraw(e);
88 
89  SwapBuffers();
90  }
override void TriDevs.TriEngine.GameWindow2D.OnResize ( EventArgs  e)
protected
60  {
61  base.OnResize(e);
62 
63  GL.Viewport(0, 0, ClientRectangle.Width, ClientRectangle.Height);
64 
65  GL.MatrixMode(MatrixMode.Projection);
66 
67  GL.LoadIdentity();
68 
69  GL.Ortho(0, ClientRectangle.Width - 1, ClientRectangle.Height - 1, 0, -1, 1);
70 
71  GL.MatrixMode(MatrixMode.Modelview);
72  }

Property Documentation

Color TriDevs.TriEngine.GameWindow2D.ClearColor
getsetprotected

Gets or sets the clear color for this window.


The documentation for this class was generated from the following file: