private void RenderTexturedPlane() { GL.PushAttrib(AttribMask.TextureBit | AttribMask.EnableBit); LightingShaderProgram.Texture1 = FileTexture; //FileTexture.Bind(); LightingShaderProgram.Activate(); GL.PushMatrix(); float width = FileTexture.Picture.Width / (float)FileTexture.Picture.Height; GLHelpers.PlaneMesh(width, 1, 3, -0.25f); GL.PopMatrix(); ShaderProgram.DisableShaders(); GL.PopAttrib(); }
private void GLElement_GLRenderStarted(object sender, EventArgs e) { #region FBO start if (UseFrameBuffer) { FBO.Activate(); FBO.FBOInitializeView(GLElement1.PerspectiveProjection, TransformOuter.Location.Z); } else { FBO.Deactivate(); } #endregion RenderToBuffer(); #region FBO finish if (UseFrameBuffer) { FBO.Deactivate(); GLElement1.InitializeView(); GL.ClearColor(0, .3f, .5f, 1); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.LoadIdentity(); // Now bind the texture to use it GL.ActiveTexture(TextureUnit.Texture0); FBO.Bind(); GLHelpers.Color4(Colors.Black); // to prevent it from being transparent // Tranform TransformOuter.Apply(); // Render with shader LightingShaderProgram.Texture1 = FBO.Texture; LightingShaderProgram.Activate(); //GLHelpers.Plane(1.3, 1.3, 0); // put it on a plane GLHelpers.Cube2D(1.7); // put it on a cube // Do some cleanup TransformOuter.Remove(); Texture2D.Disable2DTextures(); ShaderProgram.DisableShaders(); } #endregion }
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(); }
/// <summary>Load the shaders from disk and set them up</summary> private void InitializeShaders() { WrippleShaderProgram = new WrippleShaderProgram(); LightingShaderProgram = new LightingShaderProgram(); PatternShaderProgram = new PatternShaderProgram(); }