Fix small errors in driver.

This commit is contained in:
H. Utku Maden 2023-09-22 21:23:59 +03:00
parent 118b50cee2
commit 959788563f
Signed by: themixedupstuff
GPG Key ID: 25A001B636F17843
6 changed files with 34 additions and 16 deletions

@ -16,7 +16,7 @@ namespace Quik.OpenGL
private delegate void GLI4Proc(int x, int y, int z, int w);
private delegate void GLF4Proc(float x, float y, float z, float w);
private delegate void DrawElementsProc(GLEnum primitive, int size, GLEnum type, void *offset);
private delegate void DrawArraysProc(GLEnum primitive, int size, void *offset);
private delegate void DrawArraysProc(GLEnum primitive, int first, int offset);
private delegate void GetIntegervProc(GLEnum pname, int *data);
private delegate void GetFloatvProc(GLEnum pname, float *data);
private delegate byte* GetStringProc(GLEnum pname);
@ -88,7 +88,7 @@ namespace Quik.OpenGL
public static void DrawElements(GLEnum primitive, int count, GLEnum type, int offset) => _drawElements(primitive, count, type, (void*)offset);
[MethodImpl(AggressiveInlining)]
public static void DrawArrays(GLEnum primitive, int count, int offset) => _drawArrays(primitive, count, (void*)offset);
public static void DrawArrays(GLEnum primitive, int offset, int count) => _drawArrays(primitive, offset, count);
[MethodImpl(AggressiveInlining)]
public static void Get(GLEnum pname, out int value)

@ -93,7 +93,7 @@ namespace Quik.OpenGL
QMat4.Orthographic(out QMat4 matrix, view);
GL.UseProgram(program);
GL.Uniform1(iMaxZ, queue.ZDepth);
GL.Uniform1(iMaxZ, queue.ZDepth+1);
GL.UniformMatrix4(m4Transforms, false, in matrix);
GL.Uniform1(fSdfThreshold, 0.0f);
GL.Uniform1(txTexture, 0);
@ -116,7 +116,7 @@ namespace Quik.OpenGL
GL.Uniform1(iEnableTexture, 0);
}
GL.DrawArrays(GL_TRIANGLES, call.Count, call.Start);
GL.DrawElements(GL_TRIANGLES, call.Count, GL_UNSIGNED_INT, sizeof(int)*call.Start);
}
}
@ -138,6 +138,7 @@ namespace Quik.OpenGL
int shader = GL.CreateShader(type);
GL.ShaderSource(shader, text);
GL.CompileShader(shader);
if (CheckShader(shader, out string msg) == false)
{
@ -157,7 +158,7 @@ namespace Quik.OpenGL
GL.GetShader(shader, GL_COMPILE_STATUS, out int i);
if (i != (int)GL_OK)
if (i != (int)GL_TRUE)
{
message = GL.GetShaderInfoLog(shader);
return false;
@ -229,15 +230,13 @@ namespace Quik.OpenGL
public DrawData(GL21Driver driver, DrawQueue queue)
{
int a = 0, b = 0, c = 0, d = 0;
Queue = queue;
this.driver = driver;
VertexArray = GL.GenVertexArray();
GL.GenBuffers(4, out a);
vbo1 = a;
vbo2 = b;
ebo1 = c;
ebo2 = d;
GL.GenBuffers(1, out vbo1);
GL.GenBuffers(1, out vbo2);
GL.GenBuffers(1, out ebo1);
GL.GenBuffers(1, out ebo2);
isDisposed = false;
}
@ -257,7 +256,11 @@ namespace Quik.OpenGL
GL.VertexAttribPointer(driver.v2Position, 2, GL_FLOAT, false, QuikVertex.Stride, QuikVertex.PositionOffset);
GL.VertexAttribIPointer(driver.iZIndex, 1, GL_UNSIGNED_INT, QuikVertex.Stride, QuikVertex.ZIndexOffset);
GL.VertexAttribPointer(driver.v2TexPos, 2, GL_FLOAT, false, QuikVertex.Stride, QuikVertex.TextureCoordinatesOffset);
GL.VertexAttribPointer(driver.v4Color, 4, GL_FLOAT, false, QuikVertex.Stride, QuikVertex.ColorOffset);
GL.VertexAttribPointer(driver.v4Color, 4, GL_UNSIGNED_BYTE, true, QuikVertex.Stride, QuikVertex.ColorOffset);
GL.EnableVertexAttribArray(driver.v2Position);
GL.EnableVertexAttribArray(driver.iZIndex);
GL.EnableVertexAttribArray(driver.v2TexPos);
GL.EnableVertexAttribArray(driver.v4Color);
GL.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo);
GL.BufferData(GL_ELEMENT_ARRAY_BUFFER, Queue.ElementCount * sizeof(int), Queue.ElementArray, GL_STREAM_DRAW);

@ -3,6 +3,8 @@ namespace Quik.OpenGL
public enum GLEnum : int
{
GL_OK = 0,
GL_TRUE = 1,
GL_FALSE = 0,
GL_MAJOR_VERSION = 0x821B,
GL_MINOR_VERSION = 0x821C,
GL_VENDOR = 0x1F00,

@ -2,7 +2,7 @@
* QUIK: User Interface Kit
* Copyright (C) 2023 Halit Utku Maden, et al.
*/
#version 110
#version 120
varying vec2 fv2TexPos;
varying vec4 fv4Color;

@ -2,7 +2,7 @@
* QUIK: User Interface Kit
* Copyright (C) 2023 Halit Utku Maden, et al.
*/
#version 110
#version 120
attribute vec2 v2Position; /**< The vertex position.*/
attribute int iZIndex; /**< The z index. */
@ -21,5 +21,5 @@ void main(void)
gl_Position = v * m4Transforms;
fv2TexPos = v2TexPos;
fv4Color = fv4Color;
fv4Color = v4Color;
}

@ -1,6 +1,9 @@
using Quik;
using Quik.CommandMachine;
using Quik.Controls;
using Quik.OpenTK;
namespace QuikDemo
{
public static class Program
@ -9,7 +12,17 @@ namespace QuikDemo
public static void Main(string[] args)
{
Application.Run(new Quik.Controls.View());
Application.Run(new EmptyView());
}
}
public class EmptyView : View
{
protected override void PaintBegin(CommandQueue cmd)
{
base.PaintBegin(cmd);
cmd.Rectangle(new QRectangle(0, 0, 16, 16));
}
}
}