04.10.2020
+ render pipeline system for more control about the renderering. + Log system + Framebuffer system ~ Default shader was moved to pipelines.
This commit is contained in:
parent
97e638d9d9
commit
820d6ce700
34 changed files with 660 additions and 106 deletions
35
SMCode/SM.OGL/Framebuffer/ColorAttachment.cs
Normal file
35
SMCode/SM.OGL/Framebuffer/ColorAttachment.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.OGL.Texture;
|
||||
|
||||
namespace SM.OGL.Framebuffer
|
||||
{
|
||||
public class ColorAttachment : TextureBase
|
||||
{
|
||||
public int AttachmentID { get; }
|
||||
|
||||
public FramebufferAttachment FramebufferAttachment => FramebufferAttachment.ColorAttachment0 + AttachmentID;
|
||||
public DrawBufferMode DrawBufferMode => DrawBufferMode.ColorAttachment0 + AttachmentID;
|
||||
public ReadBufferMode ReadBufferMode => ReadBufferMode.ColorAttachment0 + AttachmentID;
|
||||
public DrawBuffersEnum DrawBuffersEnum => DrawBuffersEnum.ColorAttachment0 + AttachmentID;
|
||||
|
||||
public ColorAttachment(int attachmentId)
|
||||
{
|
||||
AttachmentID = attachmentId;
|
||||
}
|
||||
|
||||
public void Generate(Framebuffer f)
|
||||
{
|
||||
_id = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, _id);
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8,
|
||||
(int) f.Size.X, (int) f.Size.Y,
|
||||
0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMinFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue