Я делаю 2D игру из песочницы.
Когда я обращаюсь, чтобы использовать свой пользовательский кадр, вместо того, что сделано системой, произошли промежутки. Некоторое смещение пикселя между различными притяжениями, или это называется проблемой «полуэкселя», но это , кажется, < /em>, что не так. Тестирование глубины. < /li>
Я попытался защелкнуть пиксели. < /li>
Я пытался использовать Highp < /code> float в шейдерах. < /li>
< /ul>
Мой пользовательский кадр работает по-разному. выполнил то же самое.public class OglImageFrameBuffer : ImageFrameBuffer
{
public int Id, Tid;
public OglImage Img;
private Vec4 tmpVp;
private float scale;
// This is a auto-res buffer.
public OglImageFrameBuffer(float scl = 1)
{
scale = scl;
Id = GL.GenFramebuffer();
Tid = GL.GenTexture();
NativeManager.I0.Remind(Dispose);
Resize0();
Application.Resize.Add($"spectrum:resize_fb_{Id}", Resize0);
void Resize0()
{
float w = Surface.Current.Size.X;
float h = Surface.Current.Size.Y;
resize(w * scale, h * scale);
}
}
// This is a fixed size buffer.
public OglImageFrameBuffer(float w, float h)
{
Id = GL.GenFramebuffer();
Tid = GL.GenTexture();
NativeManager.I0.Remind(Dispose);
resize(w, h);
}
public override bool HasData => false;
public override Image Output => Img;
private void resize(float w, float h)
{
Width = (int)w;
Height = (int)h;
GL.BindFramebuffer(FramebufferTarget.Framebuffer, Id);
GL.BindTexture(TextureTarget.Texture2d, Tid);
Reference = Img = new OglImage(Tid, (int)w, (int)h);
Img.NotFlipY = true;
GL.TexImage2D(TextureTarget.Texture2d, 0, InternalFormat.Rgba8, (int)w, (int)h, 0, PixelFormat.Rgba, PixelType.UnsignedByte, (byte[])null);
GL.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
GL.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
GL.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameteri(TextureTarget.Texture2d, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2d, Tid, 0);
FramebufferStatus status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
if (status != FramebufferStatus.FramebufferComplete)
{
throw new Exception($"Cannot make framebuffer: status = {Enum.GetName(status)}.");
}
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
GL.BindTexture(TextureTarget.Texture2d, 0);
Viewport = new Vec4(0, 0, (int)w, (int)h);
}
public override void Begin(Graphics graphics)
{
tmpVp = graphics.ViewportArray;
graphics.Flush();
graphics.Viewport(Viewport);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, Id);
GL.ClearColor(0, 0, 0, 0);
GL.Clear(ClearBufferMask.ColorBufferBit);
}
public override void End(Graphics graphics)
{
graphics.Flush();
graphics.Viewport(tmpVp);
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
}
public void Dispose()
{
GL.DeleteFramebuffer(Id);
Img.Dispose();
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ramebuffer
OpenGL - сияющие зазоры между плитками при рисунке в рамку Bramebuffer ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Почему при использовании гибкой обмотки возникают зазоры по поперечной оси?
Anonymous » » в форуме CSS - 0 Ответы
- 9 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Почему при использовании гибкой обмотки возникают зазоры по поперечной оси?
Anonymous » » в форуме CSS - 0 Ответы
- 14 Просмотры
-
Последнее сообщение Anonymous
-