예제 #1
0
        /// <summary>Initialize the scene, attach the GLControl events, and start the timer</summary>
        private void SetupGLControl()
        {
            if (glControl == null)
            {
                return;
            }

            glControl.MakeCurrent();
            transformActive = transformInner;
            onGLInitialized();

            glControl.Resize     += new EventHandler(glControl_Resize);
            glControl.MouseDown  += new System.Windows.Forms.MouseEventHandler(GlControl_MouseDown);
            glControl.MouseLeave += new EventHandler(GlControl_MouseLeave);
            glControl.MouseMove  += new System.Windows.Forms.MouseEventHandler(GlControl_MouseMove);
            glControl.MouseUp    += new System.Windows.Forms.MouseEventHandler(GlControl_MouseUp);
            glControl.MouseWheel += new System.Windows.Forms.MouseEventHandler(GlControl_MouseWheel);
            glControl.KeyDown    += new System.Windows.Forms.KeyEventHandler(GlControl_KeyDown);
            glControl.KeyUp      += new System.Windows.Forms.KeyEventHandler(GlControl_KeyUp);

            if (IsTimerEnabled)
            {
                timer.Start();
            }
        }
예제 #2
0
        private void RenderTexturedCube(bool useShader)
        {
            GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit);
            if (useShader)
            {
                GLHelpers.Color4(Colors.Transparent);
                LightingShaderProgram.Texture1 = CirclesTexture;
                LightingShaderProgram.Activate();
            }
            else
            {
                GLHelpers.Color4(Colors.Black);
                GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Replace);
                //GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Decal);
                CirclesTexture.Bind();
            }

            var transformCube = new TransformGL(new Vector3(-.4f, -.4f, 0));

            transformCube.Apply();
            GLHelpers.Cube2D(.5);
            transformCube.Remove();

            transformCube.Location = new Vector3(0, 0, 0);
            transformCube.Apply();
            GLHelpers.Cube2D(.25);
            transformCube.Remove();

            transformCube.Location = new Vector3(.2f, .2f, 0);
            transformCube.Apply();
            GLHelpers.Cube2D(.125);
            transformCube.Remove();

            transformCube.Location = new Vector3(.3f, .3f, 0);
            transformCube.Apply();
            GLHelpers.Cube2D(.06125);
            transformCube.Remove();

            // cleanup
            ShaderProgram.DisableShaders();
            GL.PopAttrib();
        }