public static void Main(string[] args) { Glfw.GLFWvidmode desktopMode; Glfw.GLFWvidmode[] availableModes = new Glfw.GLFWvidmode[MAX_NUMBER_OF_MODES]; int modeCount; // Initialize GLFW if(Glfw.glfwInit() == Gl.GL_FALSE) { return; } // Show desktop video mode Glfw.glfwGetDesktopMode(out desktopMode); Console.WriteLine("Desktop mode: {0} x {1} x {2}", desktopMode.Width, desktopMode.Height, desktopMode.RedBits + desktopMode.GreenBits + desktopMode.BlueBits); // List available video modes modeCount = Glfw.glfwGetVideoModes(availableModes, MAX_NUMBER_OF_MODES); Console.WriteLine("Available modes:"); for(int i = 0; i < modeCount; i++) { Console.WriteLine("{0}: {1} x {2} x {3}", i, availableModes[i].Width, availableModes[i].Height, availableModes[i].RedBits + availableModes[i].GreenBits + availableModes[i].BlueBits); } // Terminate GLFW Glfw.glfwTerminate(); Console.Write("\n\nPress Enter to exit..."); Console.ReadLine(); }
public static void Initialise(int width, int height, int zoomOverride) { Graphics.ScreenWidth = width; Graphics.ScreenHeight = height; lock (RenderLockBlob) { GraphicsThread = Thread.CurrentThread; if (Glfw.glfwInit() != 1) throw new Exception("GLFW initialisation failed. No, I have no idea why either."); Glfw.GLFWvidmode vidDesktop = new Glfw.GLFWvidmode(); // not necessary b/c struct but whatever, man! Glfw.glfwGetDesktopMode(out vidDesktop); if (zoomOverride == 0) { int zoomLevel = 1; if (vidDesktop.Width < 1280 || vidDesktop.Height < 800) { /* MessageBox.Show("Your screen resolution is only " + vidDesktop.Width.ToString() + "x" + vidDesktop.Height.ToString() + "! The window will be displayed at 1x zoom level, whereas " + "the beautiful and glorious game designers envisioned it for 2x.\n\nAh well. Who cares, right?", "Small Screen", MessageBoxButtons.OK, MessageBoxIcon.Warning);*/ } while ((ScreenWidth * (zoomLevel * 2)) <= vidDesktop.Width && (ScreenHeight * (zoomLevel * 2)) <= vidDesktop.Height) { zoomLevel *= 2; } if (Glfw.glfwOpenWindow(zoomLevel * ScreenWidth, zoomLevel * ScreenHeight, 0, 0, 0, 8, 16, 0, Glfw.GLFW_WINDOW) != 1) throw new Exception("Failed to create GLFW window, for whatever reason."); } else { if (Glfw.glfwOpenWindow(zoomOverride * ScreenWidth, zoomOverride * ScreenHeight, 0, 0, 0, 8, 16, 0, Glfw.GLFW_WINDOW) != 1) throw new Exception("Failed to create GLFW window, for whatever reason."); } windowCloseFunc = new Glfw.GLFWwindowclosefun(OnWindowClose); Glfw.glfwSetWindowCloseCallback(windowCloseFunc); NPOTAllowed = Gl.glGetString(Gl.GL_EXTENSIONS).ToLower().Split(' ') .Contains("gl_arb_texture_non_power_of_two"); // Future: Fallback to gl_*_texture_rectangle where possible? Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); //Glu.gluOrtho2D(0, ScreenWidth, ScreenHeight, 0); Gl.glOrtho(0, ScreenWidth, ScreenHeight, 0, -1000, 1000); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); Gl.glEnable(Gl.GL_BLEND); } //Texture.SetTexture("Special Tiles", new Texture("specialtiles.png"), false); }
public void Initialise(int zoomOverride) { lock (RenderLockBlob) { GraphicsThread = Thread.CurrentThread; if (Glfw.glfwInit() != 1) throw new Exception("GLFW initialisation failed. No, I have no idea why either."); Glfw.GLFWvidmode vidDesktop = new Glfw.GLFWvidmode(); // not necessary b/c struct but whatever, man! Glfw.glfwGetDesktopMode(out vidDesktop); if (zoomOverride == 0) { int zoomLevel = 1; while ((Width * (zoomLevel * 2)) <= vidDesktop.Width && (Height * (zoomLevel * 2)) <= vidDesktop.Height) { zoomLevel *= 2; } if (Glfw.glfwOpenWindow(zoomLevel * Width, zoomLevel * Height, 0, 0, 0, 8, 16, 0, Glfw.GLFW_WINDOW) != 1) throw new Exception("Failed to create GLFW window, for whatever reason."); } else { if (Glfw.glfwOpenWindow(zoomOverride * Width, zoomOverride * Height, 0, 0, 0, 8, 16, 0, Glfw.GLFW_WINDOW) != 1) throw new Exception("Failed to create GLFW window, for whatever reason."); } windowCloseFunc = new Glfw.GLFWwindowclosefun(OnWindowClose); Glfw.glfwSetWindowCloseCallback(windowCloseFunc); NPOTAllowed = Gl.glGetString(Gl.GL_EXTENSIONS).ToLower().Split(' ') .Contains("gl_arb_texture_non_power_of_two"); // Future: Fallback to gl_*_texture_rectangle where possible? Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); //Glu.gluOrtho2D(0, Width, Height, 0); Gl.glOrtho(0, Width, Height, 0, -1000, 1000); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); Gl.glEnable(Gl.GL_BLEND); } }