Skip to content

Commit c718522

Browse files
committed
Fix global headless context not being used
Didn't update a field, so opengl was failing to use any buffers at all :) that took a ridiculous amount of debugging to find, since it just caused a segfault with a null buffer.
1 parent 8d6e91e commit c718522

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

packages/arisu-gfx/buffer/gl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function GLBuffer.new(descriptor)
1313
local handle = ffi.new("GLuint[1]")
1414
gl.createBuffers(1, handle)
1515

16-
-- Allocate the buffer (necessary for setSlice to work)
16+
-- Allocate the buffer (might be necessary for setSlice to work)
1717
gl.namedBufferData(handle[0], descriptor.size, nil, gl.DYNAMIC_DRAW)
1818

1919
local isUniform = false

packages/arisu-gfx/command_buffer/gl.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ function GLCommandBuffer:execute()
6363
print("created vao", vao.id)
6464
end
6565
vao = vaos[texture.context]
66-
print("binding vao")
6766
vao:bind()
6867

6968
gl.bindFramebuffer(gl.FRAMEBUFFER, texture.framebuffer)

packages/arisu-gfx/device/gl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local GLSampler = require("arisu-gfx.sampler.gl")
88

99
---@class gfx.gl.Device
1010
---@field public queue gfx.gl.Queue
11-
---@field private ctx gfx.gl.Context
11+
---@field ctx gfx.gl.Context
1212
local GLDevice = {}
1313
GLDevice.__index = GLDevice
1414

packages/arisu-gfx/surface/gl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end
1616
---@param device gfx.gl.Device
1717
---@param config gfx.SurfaceConfig
1818
function GLSurface:configure(device, config)
19-
local context = GLContext.fromWindow(self.window, device.globalContext)
19+
local context = GLContext.fromWindow(self.window, device.ctx)
2020
return GLSwapchain.new(context)
2121
end
2222

packages/arisu-opengl/init.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ffi.cdef([[
1313
typedef intptr_t GLintptr;
1414
typedef intptr_t GLsizeiptr;
1515
typedef void* GLsync;
16+
typedef uint8_t GLboolean;
1617
1718
typedef void (*GLDEBUGPROC)(unsigned int, unsigned int, unsigned int, unsigned int, int, const char*, const void*);
1819
]])
@@ -25,6 +26,8 @@ ffi.cdef([[
2526
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices);
2627
void glDeleteTextures(GLsizei n, const GLuint* textures);
2728
char* glGetString(GLenum name);
29+
void glGetIntegerv(GLenum pname, GLint* data);
30+
GLenum glGetError();
2831
void glEnable(GLenum cap);
2932
void glDisable(GLenum cap);
3033
void glBlendFunc(GLenum sfactor, GLenum dfactor);
@@ -95,6 +98,9 @@ local nonCoreFnDefs = {
9598
glSamplerParameteri = "void(*)(GLuint, GLenum, GLint)",
9699
glSamplerParameterf = "void(*)(GLuint, GLenum, GLfloat)",
97100
glBindSampler = "void(*)(GLuint, GLuint)",
101+
102+
glIsVertexArray = "GLboolean(*)(GLuint)",
103+
glIsBuffer = "GLboolean(*)(GLuint)",
98104
}
99105

100106
---@type fun(name: string): function
@@ -471,4 +477,24 @@ return {
471477

472478
---@type fun(source: number, type: number, severity: number, count: number, ids: ffi.cdata*, enabled: number)
473479
debugMessageControl = C.glDebugMessageControl,
480+
481+
---@type fun(pname: number): number
482+
getInteger = function(pname)
483+
local data = ffi.new("GLint[1]")
484+
C.glGetIntegerv(pname, data)
485+
return data[0]
486+
end,
487+
488+
---@type fun(): number
489+
getError = C.glGetError,
490+
491+
---@type fun(id: number): boolean
492+
isVertexArray = function(id)
493+
return C.glIsVertexArray(id) ~= 0
494+
end,
495+
496+
---@type fun(id: number): boolean
497+
isBuffer = function(id)
498+
return C.glIsBuffer(id) ~= 0
499+
end,
474500
}

0 commit comments

Comments
 (0)