Beispiel #1
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);
        }
Beispiel #2
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);
        }