Ejemplo n.º 1
0
        public MainForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            Logger.SetLogControl(richTextBox1);
            glWin = new GLControl();
            splitContainer2.Panel2.Controls.Add(glWin);
            OpenTK.Toolkit.Init();
            glWin.CreateControl();
            glWin.CreateGraphics();
            glWin.Dock      = DockStyle.Fill;
            glWin.BackColor = Color.DarkGray;
            glWin.BringToFront();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //
            Scene.Init(glWin);
            glWin.KeyDown       += glWin_KeyPress;
            glWin.KeyUp         += glWin_KeyRelease;
            glWin.MouseMove     += glWin_MouseMove;
            glWin.MouseWheel    += glWin_MouseWheel;
            glWin.Paint         += glWin_Paint;
            RenderTimer.Interval = 15;
            RenderTimer.Tick    += Repaint;
            RenderTimer.Start();
        }
Ejemplo n.º 2
0
 public void LevelChoice(string Choice)
 {
     GLD.Visible          = true;
     HealthPanel.Visible  = true;
     LevelChooser.Visible = false;
     mainMenu1.Visible    = false;
     GLD.BringToFront();
     HealthPanel.BringToFront();
     LevelStart.Invoke(Choice);
 }
Ejemplo n.º 3
0
 public void Reset()
 {
     if (glControl != null)
     {
         Destroy();
     }
     scaledScreen       = new uint[imageScaler.ResizedX * imageScaler.ResizedY];
     glControl          = new GLControl(new GraphicsMode());
     glControl.Location = Point.Empty;
     glControl.Size     = renderTarget.Size;
     glControl.Visible  = true;
     glControl.TabStop  = false;
     glControl.Enabled  = false;
     renderTarget.Controls.Add(glControl);
     renderTarget.FindForm().Show(); //Need this in here when running a rom from double click, may cause problems elsewhere?
     glControl.VSync = false;
     glControl.BringToFront();
     GL.ClearColor(Color.Black);
     GL.MatrixMode(MatrixMode.Projection);
     GL.LoadIdentity();
     GL.Ortho(0, renderTarget.Width, renderTarget.Height, 0, -1, 1); // Bottom-left corner pixel has coordinate (0, 0)
     GL.Viewport(0, 0, renderTarget.Width, renderTarget.Height);     // Use all of the glControl painting area
     GL.Enable(EnableCap.Texture2D);
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
     textureName = GL.GenTexture();
     GL.BindTexture(TextureTarget.Texture2D, textureName);
     GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, new int[] { (int)TextureWrapMode.Clamp });//Clamp to edges
     GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, new int[] { (int)TextureWrapMode.Clamp });
     if (smoothOutput)
     {
         GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, new int[] { (int)TextureMagFilter.Linear });
         GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, new int[] { (int)TextureMagFilter.Linear });
     }
     else
     {
         GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, new int[] { (int)TextureMagFilter.Nearest });
         GL.TexParameterI(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, new int[] { (int)TextureMagFilter.Nearest });
     }
     GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, new int[] { (int)TextureEnvMode.Modulate }); //Enables blending and lighting
     LoadCharSheet();
 }
Ejemplo n.º 4
0
        // Called on load
        public void Init()
        {
            Viewport = new GLControl();
            Controls.Add(Viewport);
            Viewport.BringToFront();

            Viewport.Paint  += Viewport_Paint;
            Viewport.Resize += Viewport_Resize;
            Viewport.Dock    = DockStyle.Fill;
            scene            = new Scene(Viewport);

            //dont like doing this need a Renderer.InitShaders() or something
            ColorShader colorShader = new ColorShader("Shaders\\ColorVertexShader.glsl", "Shaders\\ColorFragmentShader.glsl");

            scene.Renderer.ShaderManager.AddShader("Color", colorShader);

            scene.Renderer.Start();
            UpdateSceneUI();

            Application.Idle += Application_Idle;

            Viewport_Resize(Viewport, EventArgs.Empty);
        }