Ejemplo n.º 1
0
        public void compileShader(GLSLShaderConfig config)
        {
            if (config.program_id != -1)
            {
                GL.DeleteProgram(config.program_id);
            }

            GLShaderHelper.CreateShaders(config);
        }
Ejemplo n.º 2
0
        private void glControl1_Load(object sender, EventArgs e)
        {
            GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height);
            GL.ClearColor(System.Drawing.Color.Black);
            GL.Enable(EnableCap.DepthTest);
            //glControl1.SwapBuffers();
            //glControl1.Invalidate();
            Debug.WriteLine("GL Cleared");
            Debug.WriteLine(GL.GetError());

            this.glloaded = true;

            //Generate Geometry VBOs
            GL.GenBuffers(1, out quad_vbo);
            GL.GenBuffers(1, out quad_ebo);

            //Bind Geometry Buffers
            int arraysize = sizeof(float) * 4 * 3;

            //Upload vertex buffer
            GL.BindBuffer(BufferTarget.ArrayBuffer, quad_vbo);
            //Allocate to NULL
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(arraysize), (IntPtr)null, BufferUsageHint.StaticDraw);
            //Add verts data
            GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)0, (IntPtr)arraysize, quadverts);

            //Upload index buffer
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, quad_ebo);
            GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(sizeof(Int32) * 6), quadindices, BufferUsageHint.StaticDraw);


            //Compile Shaders
            string vvs, ffs;
            int    vertex_shader_ob, fragment_shader_ob;

            vvs = GLSL_Preprocessor.Parser("Shaders/Text_VS.glsl");
            ffs = GLSL_Preprocessor.Parser("Shaders/Text_FS.glsl");
            //Compile Texture Shaders
            GLShaderHelper.CreateShaders(vvs, ffs, out vertex_shader_ob,
                                         out fragment_shader_ob, out shader_program);


            //Setup default program
            GL.UseProgram(shader_program);


            //Load Sample texture
            //Test BMP Image Class
            BMPImage bm = new BMPImage("courier.bmp");

            sampleTex = bm.GLid;


            glControl1.Invalidate();
        }