/tech/ - Tech

Technology.

catalog
Mode: Reply
Name
E-mail
Subject
Message

Max message length: 8192

Files

Max file size: 80.00 MB

Max files: 5

Password

(used to delete files and postings)

Misc

Remember to follow the rules


(176.19 KB 400x267 1557932957929.gif)
What are you working on? Comrade 10/16/2019 (Wed) 03:13:47 No. 2580
This is the type of thread that you can write in every time you visit the site! You can do anything from use this as a personal log for your project, to sharing what you're hacking on at the moment, to critique something some else did in the thread, or request help with a bug you're struggling with. I'm looking forward to hearing what you guys are up to!
Personally I've been struggling to get a basic OpenGL program running on GBM without Xorg or Wayland. I'm getting no error messages despite my assertions and I've followed sporadic documentation on the internet and header files to the best of my ability. Any ideas what could be wrong?

#include [orange]fcntl.h>
#include [orange]assert.h>
#include [orange]unistd.h>

#include [orange]gbm.h>
#include [orange]EGL/egl.h>
#include [orange]EGL/eglext.h>
#include [orange]GL/gl.h>

int main(void) {
// Note screen information hardcoded
EGLint attributes[] = {
EGL_RED_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};

// You should be able to select from available /dev/dri/card*
// Is there a ioctl to get screen information?
int fd = open("/dev/dri/card0", O_RDWR);
assert(fd >= 0);

struct gbm_device *device = gbm_create_device(fd);
assert(device);

// skipped checking if neccessary extensions are in place for now
EGLDisplay display = eglGetPlatformDisplay(EGL_PLATFORM_GBM_MESA, device, NULL);
assert(display != EGL_NO_DISPLAY);
assert(eglInitialize(display, NULL, NULL));

// skipped config searching for now
EGLConfig config;
EGLint num_config;
assert(eglChooseConfig(display, attributes, &config, 1, &num_config) == EGL_TRUE);

EGLContext context = eglCreateContext(display, NULL, EGL_NO_CONTEXT, NULL);
assert(context != EGL_NO_CONTEXT);

// note width and height are hardcoded here
struct gbm_surface *window =
gbm_surface_create(device, 1280, 800, GBM_FORMAT_ARGB8888, GBM_BO_USE_SCANOUT);
assert(window);

EGLSurface surface = eglCreateWindowSurface(display, config, window, NULL);
assert(surface != EGL_NO_SURFACE);

assert(eglMakeCurrent(display, surface, surface, context) == EGL_TRUE);

assert(eglBindAPI(EGL_OPENGL_API) == EGL_TRUE);

glClearColor(1.0, 1.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();

eglSwapBuffers(display, surface);

sleep(10);

return 0;
}
>>926
Clearly the oranges are missing in my actual program, they should be replaced with a "<".
>>926
No, you will not be able to draw anything on screen without the permission of the DRM. Either authenticate yourself through the current DRM-Master (X11, Wayland, etc.) like here https://eleni.mutantstargoat.com/hikiko/2013/05/28/gbm-and-x-2/ , become the DRM-Master like here http://betteros.org/tut/graphics1.php or use DRM-KMS like here https://eleni.mutantstargoat.com/hg/index.cgi/gbm-sdl2-example . In any case, if Xorg, Wayland or Mir is already running, you'll have to communicate with them to draw on screen at some point.
>>926
forget about OpenGL, Vulkan is the future.
>>930
>No, you will not be able to draw anything on screen without the permission of the DRM. [...] In any case, if Xorg, Wayland or Mir is already running, you'll have to communicate with them to draw on screen at some point.
Thanks so much for the resources and information comrade! I'll read through them in a moment. Not sure why I wasn't able to find these myself, I looked quite hard. There is no DRM-Master currently running on my development machine, just TTY, so luckily that's not the issue.

>>931
>forget about OpenGL, Vulkan is the future.
I would have comrade, but none of the hardware I own has Vulkan support, and besides for the application I have in mind hardware support is more important than performance.
>>932
Consider using SDL. Since 2.0.6, they have a DRM-KMS backend that could potentially save you a lot of time.
>>933
>Consider using SDL. Since 2.0.6, they have a DRM-KMS backend that could potentially save you a lot of time.
I'll consider it, but I'm just playing around; time isn't too much of a concern. For now I'm just going to see what I can get going as far as my objectives are concerned without any additional libraries.

I followed along with the https://betteros.org example and got something working, but it seems a little silly in my case because I need to install libdrm for EGL to get the driver for my GPU. So what I'll try next is to use xf86drm.h and xf86drmMode.h
>>935
>So what I'll try next is to use xf86drm.h and xf86drmMode.h
Looks like I'm going to have a very busy weekend, so I likely won't be able to try this until the start of next week.
>>943
I made a bit of progress on this project. I've got a working OpenGL ES2 context using libdrm, and I've rendered a blue screen to it. The program is mostly copied from various tutorials all be it with some stylistic changes and offensive programming. I've found a few blogs and some official documentation which should let me improve on it more. I plan on doing some literate programming to improve my own comprehension. Do any of you have any suggested tools for this? I've found noweb and CWEB, but I've also seen a number of modern takes on the idea in my brief search.

Also I wrote a little partially broken responsive menu for a imageboard over at >>953, it's been awhile since I've written any CSS.
>>959
I forgot to post a update yesterday, I made a little progress with my literate programing venture using noweb, and wrote a "Red Yotsuba" theme for the imageboard menu I made the other day just cause.
(201.48 KB 498x272 tenor.gif)
reading capital. writing a script for a friends short film. learning GURPS. but mostly just working. feeling lonely and aimless but ive been worse. just trying to not get caught in the feeling that everything's going to inevitably spiral cause that ends up being a self fulfilling prophecy more often than not.
>>2591
oh, this must have been merged from /tech/, i thought it was a general hobby project thread

Delete
Report

no cookies?