ColleagueRiley / RGFW

A cross platform lightweight single-header simple-to-use window abstraction library for creating graphical programs or libraries.
zlib License
701 stars 26 forks source link

"Failed to find any valid GLX configs" error on x11 #35

Open chris-montero opened 1 month ago

chris-montero commented 1 month ago

import "core:fmt" import "core:log" //import glfw "vendor:glfw" import rgfw "external/RGFW-Odin/RGFW" import mem "core:mem"

drawRect :: proc(win : ^rgfw.window, r : rgfw.rect, color: ^[3]u8) { for x := r.x; x < (r.x + r.w); x += 1 { for y := r.y; y < (r.y + r.h); y += 1 { //index := y (4 screenSize.w) + x 4; index := y (4 800) + x 4; // TODO: DONT HARDCODE THE WIDTH

        mem.copy(&win.buffer[index], &color[0], 3 * size_of(u8));
    }
}

}

icon := []u8{0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF};

Program :: struct { window : ^rgfw.window, is_running : bool, }

init_program :: proc(program : ^Program) { program.window = rgfw.createWindow("Colo teroritta", { 400, 400, 800, 800 }, .CENTER) rgfw.window_makeCurrent(program.window)

//gl.load_up_to(3, 3, rgfw.gl_set_proc_address)

rgfw.window_setCPURender(program.window, 1)
rgfw.window_setGPURender(program.window, 0)

screen_size := rgfw.getScreenSize()
fmt.println(screen_size)

if program.window == nil {
    log.panic("RGFW failed to create the main window")
}

//rgfw.window_swapInterval(program.window, 1)
rgfw.window_setIcon(program.window, raw_data(icon), {3, 3}, 4)

program.is_running = true

}

teardown_program :: proc(program : ^Program) { program.is_running = false rgfw.window_close(program.window) }

main :: proc() { program := Program{} init_program(&program) defer teardown_program(&program)

for !rgfw.window_shouldClose(program.window) {

    // handle events
    for rgfw.window_checkEvent(program.window) != nil {
        if program.window.event.type == .quit {
            break
        }
    }

    do_drawing(&program)
}

}

do_drawing :: proc(program : ^Program) {

color1 : [3]u8 = {0, 0, 255}
drawRect(program.window, {0, 0, program.window.r.w, program.window.r.h}, &color1)

color2 : [3]u8 = {255, 0, 0}
drawRect(program.window, {200, 200, 200, 200}, &color2)

rgfw.window_swapBuffers(program.window)

}

ColleagueRiley commented 1 month ago

@chris-montero Do you mind testing the RGFW c examples? This will let me know if it's a problem with the Odin binding (which is not up-to-date) or if it's a problem with RGFW itself.

chris-montero commented 1 month ago

@ColleagueRiley I did so, and some of them work fine with the C examples.

These examples fail, along with their error messages:

ColleagueRiley commented 1 month ago

I'm transferring the issue here because I believe the source of the issue is the original code.

Could you tell me more about your GPU? I mostly would like to know what the latest version of OpenGL it supports and if it supports Vulkan.

Also the log is time stamped at Fri Sep 13 10:02:06. So it may not be relevant to this issue.

chris-montero commented 1 month ago

I have an nvidia gtx 950.

glxinfo | grep "OpenGL version" outputs this: OpenGL version string: 4.6.0 NVIDIA 550.120 Vulkan is supported. Just yesterday I was trying to set up the vulkan sdk for development, and I ran the provided vkcube executable, which ran without issues.

You're right, the log is old. I'll get a more recent version if you need it.

ColleagueRiley commented 1 month ago

@chris-montero I'll look into this issue as soon as I can. At the moment I am a bit busy. I believe the first error is caused by

this line on line 2543

XMatchVisualInfo((Display*) win->src.display, DefaultScreen((Display*) win->src.display), 32, TrueColor, vi); /*!< for RGBA backgrounds*/
ColleagueRiley commented 1 month ago

@ColleagueRiley I did so, and some of them work fine with the C examples.

These examples fail, along with their error messages:

* examples/buffer/
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  5 (X_GLXMakeCurrent)
  Serial number of failed request:  48
  Current serial number in output stream:  48
* examples/events/
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  152 (GLX)
  Minor opcode of failed request:  5 (X_GLXMakeCurrent)
  Serial number of failed request:  47
  Current serial number in output stream:  47
* examples/gl33/
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  12 (X_ConfigureWindow)
  Value in failed request:  0x0
  Serial number of failed request:  41
  Current serial number in output stream:  44
* examples/vk10/
  `zsh: segmentation fault  ./vk10`

@chris-montero These first two bugs might be fixed. I'd need to know more about the last two errors to attempt to fix them.

chris-montero commented 1 month ago

you are correct, the first two work now. The last two don't. I don't know what kind of information you want from gl33, or how I could provide you with that info.

But about examples/vk10, I think you can look here to see how to set up validation layers and a custom debug messenger and then maybe I can run that and give you some information that way.

chris-montero commented 1 month ago

Btw I tried running vk10 in gdb, and this is the backtrace:

#0  0x00007ffff65e12e0 in ?? () from /usr/lib/libnvidia-glcore.so.550.120
#1  0x00007ffff65ecb17 in ?? () from /usr/lib/libnvidia-glcore.so.550.120
#2  0x00007ffff651d4c5 in ?? () from /usr/lib/libnvidia-glcore.so.550.120
#3  0x00007ffff7a0cda0 in ?? () from /usr/lib/libGLX_nvidia.so.0
#4  0x00007ffff7d2dd78 in terminator_CreateDevice (physicalDevice=physicalDevice@entry=0x5555556db030, pCreateInfo=pCreateInfo@entry=0x7fffffffd970, pAllocator=pAllocator@entry=0x0,
    pDevice=pDevice@entry=0x7fffffffd928) at /home/chris/software/VulkanSDK/1.3.296.0/source/Vulkan-Loader/loader/loader.c:5975
#5  0x00007ffff7d37e65 in loader_create_device_chain (pd=pd@entry=0x5555556db030, pCreateInfo=pCreateInfo@entry=0x7fffffffdb80, pAllocator=pAllocator@entry=0x0, inst=inst@entry=0x555555592410,
    dev=dev@entry=0x555555704390, callingLayer=callingLayer@entry=0x0, layerNextGDPA=0x0) at /home/chris/software/VulkanSDK/1.3.296.0/source/Vulkan-Loader/loader/loader.c:5070
#6  0x00007ffff7d38aee in loader_layer_create_device (instance=instance@entry=0x0, physicalDevice=physicalDevice@entry=0x5555556daa10, pCreateInfo=pCreateInfo@entry=0x7fffffffdb80,
    pAllocator=pAllocator@entry=0x0, pDevice=pDevice@entry=0x555555566b50 <RGFW_vulkan_info+16>, layerGIPA=layerGIPA@entry=0x0, nextGDPA=0x0)
    at /home/chris/software/VulkanSDK/1.3.296.0/source/Vulkan-Loader/loader/loader.c:4445
#7  0x00007ffff7d3f9c6 in vkCreateDevice (physicalDevice=0x5555556daa10, pCreateInfo=0x7fffffffdb80, pAllocator=0x0, pDevice=0x555555566b50 <RGFW_vulkan_info+16>)
    at /home/chris/software/VulkanSDK/1.3.296.0/source/Vulkan-Loader/loader/trampoline.c:1017
#8  0x000055555555e9f5 in RGFW_deviceInitialization ()
#9  0x000055555555e44f in RGFW_initVulkan ()
#10 0x000055555555f8a1 in main ()
ColleagueRiley commented 1 month ago

@chris-montero I'll look into the vulkan example later. It's a low priority because it's an issue with an example and not with RGFW. Also for full disclosure, the vulkan example is based on contributed code rather than code I wrote myself.

I'm not sure how to start fixing gl33 issue. But it will require your assistance since the error doesn't occur with my hardware/drivers.

chris-montero commented 1 month ago

@ColleagueRiley for the gl33 example, if you can give me a patched version of the code that would produce more relevant information for you, I can run it and give you the output.

ColleagueRiley commented 1 month ago

@chris-montero I'm not entirely sure why that issue is happening. The error is a bit vague. It could mean, for example, that the window is just too large. Would you mind debugging the example and finding where the issue occurs?

chris-montero commented 2 weeks ago

@ColleagueRiley I tried to debug it with both gdb and lldb, but I guess that won't do much since it seems to be an x11 error, not a segfault or anything like that. I don't know what else to try. Do you have any suggestions?

ColleagueRiley commented 2 weeks ago

https://github.com/ColleagueRiley/RGFW/commit/f93c2fd78f8241844e5788d94892f25390733ea8

Should fix your gl33 issue

chris-montero commented 2 weeks ago

This fixes the problem. You can keep this issue to keep investigating and find a more robust fix for gl33. or do whatever you want with it i dont really care