void Instalize() { UIEngine = new UIEngine(); var settings = Settings.GetInstance(); Width = settings.Graphics.Width; Height = settings.Graphics.Height; try { GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill); //setting aditional buffer FBO = GL.GenFramebuffer(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, FBO); //Texture texture = Texture.LoadFrameBufer(Width, Height, "postprocess"); //screen = new Model(texture,pp); //Console.WriteLine(GL.GetInteger(GetPName.MaxComputeImageUniforms)); //allocation custom framebuffer buffers int RBO = GL.GenRenderbuffer(); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, RBO); //GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferStorage.Depth24Stencil8, Width, Height); GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0); GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthStencilAttachment, RenderbufferTarget.Renderbuffer, RBO); //Console.WriteLine(GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer)); GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); //enable blending GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); //GL.BlendFunc(BlendingFactor.Src1Alpha,BlendingFactor.OneMinusSrcAlpha); //enable depth test GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Less); //enable stencil GL.Enable(EnableCap.StencilTest); GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } //Loading essential shaders ShaderManager shdmMgmt = ShaderManager.GetInstance; try { shdmMgmt.LoadShader("shadow"); shdmMgmt.LoadShader("outline"); } catch (Exception e) { Console.WriteLine(e.Message); } }
void Awake() { camera = CoreEngine.gEngine.MainCamera; width = camera.Width; height = camera.Height; renderBuffer = new RenderBuffer(camera, 4, false); renderBufferId = renderBuffer.RenderBufferDraw; renderTex = renderBuffer.RenderTexture; imageBitmap = new Bitmap(width, height); form = new DynamicForm(); form.LeftMouseDown += LeftMouseDown; form.LeftMouseUp += LeftMouseUp; //postprocessing testing ppSh = new PostProcessing(camera); ShaderManager shdrm = ShaderManager.GetInstance; shdrm.LoadShader("FormPP"); shaderPP = shdrm.GetShader("FormPP"); shaderPP.ApplyShader(); shaderPP.SetUniform(0, "texture_diffuse"); //shaderPP.SetUniform(new Vector3(0.01f,0.005f,-0.01f), "colorOffset"); //aberation = (ShaderUniformVector3)shaderPP.GetUniforms[0]; //pixelAberation /= width; }
void TestTriangle() { /* * Vertex3D[] vertices = { * new Vertex3D(new Vector3( -0.5f, -0.5f, 0.0f),Vector3.Zero,Vector2.Zero), * new Vertex3D(new Vector3( 0.5f, -0.5f, 0.0f),Vector3.Zero,Vector2.Zero), * new Vertex3D(new Vector3( 0.0f, 0.5f, 0.0f),Vector3.Zero,Vector2.Zero), * }; * ms = new Mesh(vertices, new int[] { 0, 1, 2 }); */ float[] vertices = { -1.0f, -0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f }; VBO = GL.GenBuffer(); VAO = GL.GenVertexArray(); GL.BindVertexArray(VAO); GL.BindBuffer(BufferTarget.ArrayBuffer, VBO); GL.BufferData(BufferTarget.ArrayBuffer, 4 * vertices.Length, vertices, BufferUsageHint.StaticDraw); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * 4, 0); GL.EnableVertexAttribArray(0); ShaderManager shdmMgmt = ShaderManager.GetInstance; shdmMgmt.LoadShader("defscreen"); sh = shdmMgmt.GetShader("defscreen"); }
void Awake() { ImageStream = new MemoryStream(); camera = CoreEngine.gEngine.MainCamera; width = camera.Width; height = camera.Height; renderBuffer = new RenderBuffer(camera, 4, false); renderBufferId = renderBuffer.RenderBufferDraw; renderTex = renderBuffer.RenderTexture; imageBitmap = new Bitmap(width, height); //postprocessing testing ppSh = new PostProcessing(camera); ShaderManager shdrm = ShaderManager.GetInstance; shdrm.LoadShader("FormPP"); shaderPP = shdrm.GetShader("FormPP"); shaderPP.ApplyShader(); shaderPP.SetUniform(0, "texture_diffuse"); }
internal TextRenderer() { lib = new Library(); try { using (Stream file = File.OpenRead(font)) { face = new Face(lib, ReadFont(file), 0); } } catch (Exception) { string defPath = "Toys.Resourses.Fonts.reddelicious.ttf"; var assembly = IntrospectionExtensions.GetTypeInfo(typeof(ShaderManager)).Assembly; face = new Face(lib, ReadFont(assembly.GetManifestResourceStream(defPath)), 0); } face.SetPixelSizes(0, (uint)size); //projection = Matrix4.CreateOrthographicOffCenter(0, 800, 0, 600, 0f, -0.01f); ShaderManager shdmMgmt = ShaderManager.GetInstance; shdmMgmt.LoadShader("text"); shdr = shdmMgmt.GetShader("text"); shdr.ApplyShader(); shdr.SetUniform((int)TextureType.Diffuse, "text"); foreach (var uniform in shdr.GetUniforms) { if (uniform.Name == "projection") { projUniform = uniform; } else if (uniform.Name == "textColor") { colorUniform = uniform; } } charmap = Texture2D.CreateCharMap(mapSize, mapSize); }