[Mesa-users] Need help getting start with EGL/DRM/KMS/GLES2
Albert Freeman
albertwdfreeman at gmail.com
Mon Aug 31 21:10:48 PDT 2015
Well with these quick and dirty changes I made, it works fine on my
system, no segfault and the screen displays red.
--- gleskmsorg.c 2015-09-01 14:04:32.853672410 +0000
+++ gleskms.c 2015-09-01 14:03:57.797005474 +0000
@@ -24,8 +24,6 @@ EGL_CONFORMANT, EGL_OPENGL_ES2_BIT,
EGL_NONE };
static const char device_name[] = "/dev/dri/card0";
-static const uint32_t drm_mode_connector_id = 18;
-static const uint32_t drm_mode_crtc_id = 21;
int main(void) {
@@ -86,10 +84,12 @@ int main(void) {
exit(EXIT_FAILURE);
}
+ drmModeRes *res;
drmModeConnector *conn;
uint32_t conn_id, width, height;
drmModeModeInfo modeinfo;
- conn = drmModeGetConnector(fd, drm_mode_connector_id);
+ res = drmModeGetResources(fd);
+ conn = drmModeGetConnector(fd, *res->connectors);
conn_id = conn->connector_id;
width = conn->modes[0].hdisplay;
height = conn->modes[0].vdisplay;
@@ -129,7 +129,7 @@ int main(void) {
exit(EXIT_FAILURE);
}
- ret = drmModeSetCrtc(fd, drm_mode_crtc_id, drm_fb_id, 0, 0, &conn_id, 1,
+ ret = drmModeSetCrtc(fd, *res->crtcs, drm_fb_id, 0, 0, &conn_id, 1,
&modeinfo);
if (ret) {
printf("failed to set mode: %m\n");
@@ -143,8 +143,8 @@ int main(void) {
gbm_surface_destroy(gs);
eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroyContext(dpy, ctx);
-// eglDestroySurface(dpy, surface);
-// eglTerminate(dpy);
+ eglDestroySurface(dpy, surface);
+ eglTerminate(dpy);
gbm_device_destroy(gbm);
close(fd);
return 0;
More information about the mesa-users
mailing list