Esempio n. 1
0
    private void OnConfigure(object o, ConfigureEventArgs args)
    {
        if (!MakeCurrent())
        {
            LogManager.Log(LogLevel.Warning, "MakeCurrent() - OnConfigure failed");
            return;
        }

        GlUtil.ContextValid = true;

        // setup opengl state and transform
        gl.Disable(gl.DEPTH_TEST);
        gl.Disable(gl.CULL_FACE);
        gl.Enable(gl.TEXTURE_2D);
        gl.Enable(gl.BLEND);
        gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);

        gl.ClearColor(0f, 0f, 0f, 0f);
        gl.Viewport(0, 0, Allocation.Width, Allocation.Height);
        gl.MatrixMode(gl.PROJECTION);
        gl.LoadIdentity();
        gl.Ortho(0, Allocation.Width, Allocation.Height, 0,
                 -1.0f, 1.0f);
        gl.MatrixMode(gl.MODELVIEW);
        gl.LoadIdentity();

        GlUtil.Assert("After setting opengl transforms");

        GlUtil.ContextValid = false;
    }
Esempio n. 2
0
    private void OnExposed(object o, ExposeEventArgs args)
    {
        if (!MakeCurrent())
        {
            LogManager.Log(LogLevel.Warning, "Make Current - OnExposed failed");
            return;
        }

        GlUtil.ContextValid = true;

        gl.MatrixMode(gl.MODELVIEW);
        gl.LoadIdentity();
        gl.Scalef(Zoom, Zoom, 1f);
        gl.Translatef(Translation.X, Translation.Y, 0f);

        DrawGl();
        GlUtil.Assert("After Drawing");

        SwapBuffers();

        GlUtil.ContextValid = false;
    }