GLHelper.cs :  » Game » RealmForge » Axiom » RenderSystems » OpenGL » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » RealmForge 
RealmForge » Axiom » RenderSystems » OpenGL » GLHelper.cs
using System;
using System.Windows.Forms;
using Axiom.Configuration;
using Axiom.Graphics;
using Tao.Platform.Windows;

namespace Axiom.RenderSystems.OpenGL{
  /// <summary>
  /// Summary description for GLSupport.
  /// </summary>
  public class GLSupport : BaseGLSupport {

    public GLSupport() : base() {
    }

    /// <summary>
    ///    Uses Wgl to return the procedure address for an extension function.
    /// </summary>
    /// <param name="extension"></param>
    /// <returns></returns>
    public override IntPtr GetProcAddress(string extension) {
      return Wgl.wglGetProcAddress(extension);
    }

    /// <summary>
    ///    Query the display modes and deal with any other config options.
    /// </summary>
    public override void AddConfig() {
      Gdi.DEVMODE setting;
      int i = 0;
      int width, height, bpp, freq;
            
      bool more = User.EnumDisplaySettings(null, i++, out setting);

      while(more) {
        width = setting.dmPelsWidth;
        height = setting.dmPelsHeight;
        bpp = setting.dmBitsPerPel;
        freq = setting.dmDisplayFrequency;
      
        // filter out the lower resolutions and dupe frequencies
        if(width >= 640 && height >= 480 && bpp >= 16) {
          string query = string.Format("Width = {0} AND Height= {1} AND Bpp = {2}", width, height, bpp);

          if(engineConfig.DisplayMode.Select(query).Length == 0) {
            // add a new row to the display settings table
            engineConfig.DisplayMode.AddDisplayModeRow(width, height, bpp, false, false);
          }
        }

        // grab the current display settings
        more = User.EnumDisplaySettings(null, i++, out setting);
      }
    }

    public override Axiom.Graphics.RenderWindow CreateWindow(bool autoCreateWindow, GLRenderSystem renderSystem, string windowTitle) {
      RenderWindow autoWindow = null;

      if(autoCreateWindow) {
        EngineConfig.DisplayModeRow[] modes = 
          (EngineConfig.DisplayModeRow[])engineConfig.DisplayMode.Select("Selected = true");

        EngineConfig.DisplayModeRow mode = modes[0];

        int width = mode.Width;
        int height = mode.Height;
        int bpp = mode.Bpp;
        bool fullscreen = mode.FullScreen;

        // create a default form to use for a rendering target
        DefaultForm form = CreateDefaultForm(windowTitle, 0, 0, width, height, fullscreen);

        // create the window with the default form as the target
        autoWindow = renderSystem.CreateRenderWindow(windowTitle, width, height, bpp, fullscreen, 0, 0, true, false, form.Target);

        // set the default form's renderwindow so it can access it internally
        form.RenderWindow = autoWindow;

        // show the window
        form.Show();
      }

      return autoWindow;
    }

    public override Axiom.Graphics.RenderWindow NewWindow(string name, int width, int height, int colorDepth, bool fullScreen, int left, int top, bool depthBuffer, bool vsync, object target) {
      Win32Window window = new Win32Window();

      window.Handle = target;

      window.Create(name, width, height, colorDepth, fullScreen, left, top, depthBuffer, vsync);

      return window;
    }

    /// <summary>
    ///    Creates a default form to use for a rendering target.
    /// </summary>
    /// <remarks>
    ///    This is used internally whenever <see cref="Initialize"/> is called and autoCreateWindow is set to true.
    /// </remarks>
    /// <param name="windowTitle">Title of the window.</param>
    /// <param name="top">Top position of the window.</param>
    /// <param name="left">Left position of the window.</param>
    /// <param name="width">Width of the window.</param>
    /// <param name="height">Height of the window</param>
    /// <param name="fullScreen">Prepare the form for fullscreen mode?</param>
    /// <returns>A form suitable for using as a rendering target.</returns>
    private DefaultForm CreateDefaultForm(string windowTitle, int top, int left, int width, int height, bool fullScreen) {
      DefaultForm form = new DefaultForm();

      form.ClientSize = new System.Drawing.Size(width,height);
      form.MaximizeBox = false;
      form.MinimizeBox = false;
      form.StartPosition = FormStartPosition.CenterScreen;

      if(fullScreen) {
        form.Top = 0;
        form.Left = 0;
        form.FormBorderStyle = FormBorderStyle.None;
        form.WindowState = FormWindowState.Maximized;
        form.TopMost = true;
        form.TopLevel = true;
      }
      else {
        form.Top = top;
        form.Left = left;
        form.FormBorderStyle = FormBorderStyle.FixedSingle;
        form.WindowState = FormWindowState.Normal;
        form.Text = windowTitle;
      }

      return form;
    }
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.