public override void RenderScene() { if (MapCamera == null) { return; } GL.DepthFunc(DepthFunction.Lequal); var cam = MapCamera.cameraData; GL.PushMatrix(); foreach (var kcl in ParentEditor.CollisionObjects) { kcl.Renderer.Draw(Camera.ModelViewMatrix); } //Draw mini map and bind texture var angle = GetAngle(); var scaleX = cam.PositionX - cam.TargetX; var scaleY = cam.PositionZ - cam.TargetZ; GL.PushMatrix(); GL.Rotate(angle + -90, Vector3.UnitZ); GL.Enable(EnableCap.Texture2D); GL.DepthFunc(DepthFunction.Always); if (MapCameraTexture != null) { if (MapCameraTexture.RenderableTex == null || !MapCameraTexture.RenderableTex.GLInitialized) { MapCameraTexture.LoadOpenGLTexture(); } MapCameraTexture.RenderableTex?.Bind(); } Render2D.DrawRectangle(cam.BoundingWidth, cam.BoundingHeight, Color.FromArgb(CameraMapTransparency, Color.White), false); GL.PopMatrix(); GL.PopMatrix(); GL.DepthFunc(DepthFunction.Lequal); GL.BindTexture(TextureTarget.Texture2D, 0); GL.Disable(EnableCap.Texture2D); GL.Disable(EnableCap.DepthTest); Render2D.DrawRectangle(cam.BoundingWidth, cam.BoundingHeight, Color.Red, true); GL.Enable(EnableCap.DepthTest); foreach (var obj in CameraPoints) { obj.Draw(); } }
public void LoadCustomTexture(STGenericTexture GenericTexture) { if (GenericTexture.RenderableTex == null || !GenericTexture.RenderableTex.GLInitialized) { GenericTexture.LoadOpenGLTexture(); } CustomCubemap = GenericTexture.RenderableTex; }
private static void BindGLTexture(STGenericTexture texture, STGenericTextureMap matTex, ShaderProgram shader) { if (texture.RenderableTex == null || !texture.RenderableTex.GLInitialized) { texture.LoadOpenGLTexture(); } //If the texture is still not initialized then return if (!texture.RenderableTex.GLInitialized) { return; } GL.BindTexture(TextureTarget.Texture2D, texture.RenderableTex.TexID); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)OpenGLHelper.WrapMode[matTex.WrapU]); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)OpenGLHelper.WrapMode[matTex.WrapV]); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)OpenGLHelper.MinFilter[matTex.MinFilter]); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)OpenGLHelper.MagFilter[matTex.MagFilter]); GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, 0.0f); }
public static void BindGLTexture(STGenericMatTexture tex, ShaderProgram shader, STGenericTexture texture) { if (texture.RenderableTex == null || !texture.RenderableTex.GLInitialized) { texture.LoadOpenGLTexture(); } if (tex.Type == STGenericMatTexture.TextureType.Diffuse) { shader.SetInt("RedChannel", (int)texture.RedChannel); shader.SetInt("GreenChannel", (int)texture.GreenChannel); shader.SetInt("BlueChannel", (int)texture.BlueChannel); shader.SetInt("AlphaChannel", (int)texture.AlphaChannel); } // GL.ActiveTexture(TextureUnit.Texture0 + texid); GL.BindTexture(TextureTarget.Texture2D, texture.RenderableTex.TexID); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)STGenericMatTexture.wrapmode[tex.WrapModeS]); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)STGenericMatTexture.wrapmode[tex.WrapModeT]); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)STGenericMatTexture.minfilter[tex.MinFilter]); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)STGenericMatTexture.magfilter[tex.MagFilter]); GL.TexParameter(TextureTarget.Texture2D, (TextureParameterName)ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, 0.0f); }
private static void BindGLTexture(TextureRef tex, STGenericTexture texture) { if (texture.RenderableTex == null || !texture.RenderableTex.GLInitialized) { texture.LoadOpenGLTexture(); } //If the texture is still not initialized then return if (!texture.RenderableTex.GLInitialized) { return; } GL.BindTexture(TextureTarget.Texture2D, texture.RenderableTex.TexID); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleR, ConvertChannel(texture.RedChannel)); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleG, ConvertChannel(texture.GreenChannel)); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleB, ConvertChannel(texture.BlueChannel)); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureSwizzleA, ConvertChannel(texture.AlphaChannel)); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, ConvertTextureWrap(tex.WrapModeU)); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, ConvertTextureWrap(tex.WrapModeV)); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, ConvertMagFilterMode(tex.MaxFilterMode)); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, ConvertMinFilterMode(tex.MinFilterMode)); }
public void Draw(GL_ControlModern control, Pass pass, Vector4 sphereColor, Vector4 outlineColor) { Initialize(control, Scale); if (pass == Pass.TRANSPARENT) { GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); GL.Enable(EnableCap.Blend); } sphereVao.Enable(control); if (pass == Pass.PICKING) { control.CurrentShader = SolidColorShaderProgram; control.CurrentShader.SetVector4("color", control.NextPickingColor()); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); return; } else { } if (pass == Pass.OPAQUE && outlineColor.W != 0) { GL.Enable(EnableCap.StencilTest); GL.Clear(ClearBufferMask.StencilBufferBit); GL.ClearStencil(0); GL.StencilFunc(StencilFunction.Always, 0x1, 0x1); GL.StencilOp(StencilOp.Keep, StencilOp.Replace, StencilOp.Replace); } if (pass == PlanePass) { control.CurrentShader = DefaultShaderProgram; DefaultShaderProgram.SetVector4("highlight_color", sphereColor); if (Texture != null) { GL.ActiveTexture(TextureUnit.Texture0 + 1); DefaultShaderProgram.SetInt("texture0", 1); if (Texture.RenderableTex == null || !Texture.RenderableTex.GLInitialized) { Texture.LoadOpenGLTexture(); } GL.BindTexture(TextureTarget.Texture2D, Texture.RenderableTex.TexID); } sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); } if (pass == Pass.OPAQUE && outlineColor.W != 0) { GL.ColorMask(false, false, false, false); GL.DepthMask(false); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); GL.ColorMask(true, true, true, true); GL.DepthMask(true); } GL.Disable(EnableCap.Blend); if (pass == Pass.OPAQUE && outlineColor.W != 0) { control.CurrentShader = SolidColorShaderProgram; control.CurrentShader.SetVector4("color", new Vector4(outlineColor.Xyz, 1)); GL.LineWidth(3.0f); GL.StencilFunc(StencilFunction.Equal, 0x0, 0x1); GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace); //GL.DepthFunc(DepthFunction.Always); GL.PolygonMode(MaterialFace.Front, PolygonMode.Line); sphereVao.Use(control); GL.DrawArrays(PrimitiveType.Quads, 0, Vertices.Length); GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill); //GL.DepthFunc(DepthFunction.Lequal); GL.Disable(EnableCap.StencilTest); GL.LineWidth(2); } }