SdlGLSupport.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 » SdlGLSupport.cs
using System;
using System.Data;
using Axiom.Configuration;
using Axiom.Core;
using Axiom.Graphics;
using Tao.OpenGl;
using Tao.Sdl;

namespace Axiom.RenderSystems.OpenGL{
  /// <summary>
  ///    Summary description for SdlGLSupport.
  /// </summary>
  public class GLSupport : BaseGLSupport {
    public GLSupport() : base() {
      Sdl.SDL_Init(Sdl.SDL_INIT_VIDEO);
    }

    #region BaseGLSupport Members

    /// <summary>
    ///    Returns the pointer to the specified extension function in the GL driver.
    /// </summary>
    /// <param name="extension"></param>
    /// <returns></returns>
    public override IntPtr GetProcAddress(string extension) {
      return Sdl.SDL_GL_GetProcAddress(extension);
    }

    /// <summary>
    ///    
    /// </summary>
    public override void AddConfig() {
      // get the available OpenGL resolutions
      Sdl.SDL_Rect[] modes = Sdl.SDL_ListModes(IntPtr.Zero, Sdl.SDL_FULLSCREEN | Sdl.SDL_OPENGL);

      // add the resolutions to the config
      foreach(Sdl.SDL_Rect mode in modes) {
        int width = mode.w;
        int height = mode.h;
        // HACK: How to get bpp?  Assume 16 and 32 are available?
        int bpp = 32;

        // 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);
          }
        }
      }
    }

    /// <summary>
    ///    
    /// </summary>
    /// <param name="name"></param>
    /// <param name="width"></param>
    /// <param name="height"></param>
    /// <param name="colorDepth"></param>
    /// <param name="fullScreen"></param>
    /// <param name="left"></param>
    /// <param name="top"></param>
    /// <param name="depthBuffer"></param>
    /// <param name="vsync"></param>
    /// <param name="target"></param>
    /// <returns></returns>
    public override RenderWindow NewWindow(string name, int width, int height, int colorDepth, bool fullScreen, int left, int top, bool depthBuffer, bool vsync, object target) {
      SdlWindow window = new SdlWindow();
      window.Create(name, width, height, colorDepth, fullScreen, left, top, depthBuffer, vsync);
      return window;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="autoCreateWindow"></param>
    /// <param name="renderSystem"></param>
    /// <param name="windowTitle"></param>
    /// <returns></returns>
    public override RenderWindow CreateWindow(bool autoCreateWindow, GLRenderSystem renderSystem, string windowTitle) {
      RenderWindow autoWindow = null;

      if(autoCreateWindow) {
        // MONO: Could not cast result of Select to strongly typed data row
        DataRow[] modes = 
          (DataRow[])engineConfig.DisplayMode.Select("Selected = true");

        DataRow mode = modes[0];

        int width = (int)mode["Width"];
        int height = (int)mode["Height"];
        int bpp = (int)mode["Bpp"];
        bool fullscreen = (bool)mode["FullScreen"];

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

      return autoWindow;
    }

    #endregion BaseGLSupport Members
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.