Ejemplo n.º 1
0
 public static void Deinitialise()
 {
     // God, I do despise this bit.
     GC.KeepAlive(windowCloseFunc);
     windowCloseFunc = null;
     Texture.ForceDestroyAllTextures();
     Glfw.glfwCloseWindow();
     Glfw.glfwTerminate();
 }
Ejemplo n.º 2
0
 public void Deinitialise()
 {
     // God, I do despise this bit.
     GC.KeepAlive(windowCloseFunc);
     windowCloseFunc = null;
     // Todo: Destroy textures!
     Glfw.glfwCloseWindow();
     Glfw.glfwTerminate();
 }
Ejemplo n.º 3
0
 public static void Deinitialise()
 {
     // God, I do despise this bit.
     GC.KeepAlive(windowCloseFunc);
     windowCloseFunc = null;
     Texture.ForceDestroyAllTextures();
     Glfw.glfwCloseWindow();
     Glfw.glfwTerminate();
 }
Ejemplo n.º 4
0
 public void Deinitialise()
 {
     // God, I do despise this bit.
     GC.KeepAlive(windowCloseFunc);
     windowCloseFunc = null;
     // Todo: Destroy textures!
     Glfw.glfwCloseWindow();
     Glfw.glfwTerminate();
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        public Cube()
        {
            Glfw.glfwInit();
            Glfw.glfwOpenWindow(640, 480, 8, 8, 8, 8, 16, 0, Glfw.GLFW_WINDOW);
            Glfw.glfwSetWindowTitle(
                Gl.glGetString(Gl.GL_VENDOR) + " " +
                Gl.glGetString(Gl.GL_RENDERER) + " " +
                Gl.glGetString(Gl.GL_VERSION)
                );

            Gl.glClearColor(0.1f, 0.1f, 0.5f, 0.0f);
            Gl.glEnable(Gl.GL_DEPTH_TEST);

            vs_object = Gl.glCreateShader(Gl.GL_VERTEX_SHADER);
            fs_object = Gl.glCreateShader(Gl.GL_FRAGMENT_SHADER);

            int[] status = new int[1];

            Gl.glShaderSource(vs_object, 1, vertex_shader, null);
            Gl.glCompileShader(vs_object);
            Gl.glGetShaderiv(vs_object, Gl.GL_COMPILE_STATUS, status);
            //if (status[0] != Gl.GL_TRUE)
            //    throw new Exception("Could not compile vertex shader");

            Gl.glShaderSource(fs_object, 1, fragment_shader, null);
            Gl.glCompileShader(fs_object);
            Gl.glGetShaderiv(fs_object, Gl.GL_COMPILE_STATUS, status);
            //if (status[0] != Gl.GL_TRUE)
            //    throw new Exception("Could not compile fragment shader");

            program = Gl.glCreateProgram();
            Gl.glAttachShader(program, fs_object);
            Gl.glAttachShader(program, vs_object);

            Gl.glLinkProgram(program);
            Gl.glUseProgram(program);

            Glfw.GLFWwindowsizefun  ResizeCallback = new Glfw.GLFWwindowsizefun(Resize);
            Glfw.GLFWwindowclosefun CloseCallback  = new Glfw.GLFWwindowclosefun(Close);
            Glfw.glfwSetWindowSizeCallback(ResizeCallback);
            Glfw.glfwSetWindowCloseCallback(CloseCallback);
        }
Ejemplo n.º 7
0
Archivo: Cube.cs Proyecto: vhotur/tao
        public Cube()
        {
            Glfw.glfwInit();
            Glfw.glfwOpenWindow(640, 480, 8, 8, 8, 8, 16, 0, Glfw.GLFW_WINDOW);
            Glfw.glfwSetWindowTitle(
                Gl.glGetString(Gl.GL_VENDOR) + " " +
                Gl.glGetString(Gl.GL_RENDERER) + " " +
                Gl.glGetString(Gl.GL_VERSION)
            );

            Gl.glClearColor(0.1f, 0.1f, 0.5f, 0.0f);
            Gl.glEnable(Gl.GL_DEPTH_TEST);

            vs_object = Gl.glCreateShader(Gl.GL_VERTEX_SHADER);
            fs_object = Gl.glCreateShader(Gl.GL_FRAGMENT_SHADER);

            int[] status = new int[1];

            Gl.glShaderSource(vs_object, 1, vertex_shader, null);
            Gl.glCompileShader(vs_object);
            Gl.glGetShaderiv(vs_object, Gl.GL_COMPILE_STATUS, status);
            //if (status[0] != Gl.GL_TRUE)
            //    throw new Exception("Could not compile vertex shader");

            Gl.glShaderSource(fs_object, 1, fragment_shader, null);
            Gl.glCompileShader(fs_object);
            Gl.glGetShaderiv(fs_object, Gl.GL_COMPILE_STATUS, status);
            //if (status[0] != Gl.GL_TRUE)
            //    throw new Exception("Could not compile fragment shader");

            program = Gl.glCreateProgram();
            Gl.glAttachShader(program, fs_object);
            Gl.glAttachShader(program, vs_object);

            Gl.glLinkProgram(program);
            Gl.glUseProgram(program);

            Glfw.GLFWwindowsizefun ResizeCallback = new Glfw.GLFWwindowsizefun(Resize);
            Glfw.GLFWwindowclosefun CloseCallback = new Glfw.GLFWwindowclosefun(Close);
            Glfw.glfwSetWindowSizeCallback(ResizeCallback);
            Glfw.glfwSetWindowCloseCallback(CloseCallback);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
            }
        }