Git Product home page Git Product logo

Comments (6)

pjanx avatar pjanx commented on May 3, 2024
diff --git a/example/sdl-imageviewer/sdl-imageviewer.cc b/example/sdl-imageviewer/sdl-imageviewer.cc
index 6d2b0fec..76819716 100644
--- a/example/sdl-imageviewer/sdl-imageviewer.cc
+++ b/example/sdl-imageviewer/sdl-imageviewer.cc
@@ -229,6 +229,10 @@ bool g_load_via_sdl_image = false;
 bool  //
 draw(SDL_Window* window) {
   SDL_Surface* ws = SDL_GetWindowSurface(window);
+  if (!ws) {
+    fprintf(stderr, "draw: SDL_GetWindowSurface(): %s\n", SDL_GetError());
+    return false;
+  }
   SDL_FillRect(ws, NULL, SDL_MapRGB(ws->format, 0x00, 0x00, 0x00));
   if (g_image) {
     SDL_BlitSurface(g_image, NULL, ws, NULL);

gives me the somewhat expected:

draw: SDL_GetWindowSurface(): Unknown window pixel format

from wuffs.

pjanx avatar pjanx commented on May 3, 2024

SDL can be made to work in the following manner, which even seems to be an acceptable patch as-is:

diff --git a/example/sdl-imageviewer/sdl-imageviewer.cc b/example/sdl-imageviewer/sdl-imageviewer.cc
index 6d2b0fec..1464c94c 100644
--- a/example/sdl-imageviewer/sdl-imageviewer.cc
+++ b/example/sdl-imageviewer/sdl-imageviewer.cc
@@ -229,6 +229,15 @@ bool g_load_via_sdl_image = false;
 bool  //
 draw(SDL_Window* window) {
   SDL_Surface* ws = SDL_GetWindowSurface(window);
+  if (!ws) {
+    SDL_Renderer *r = SDL_CreateRenderer(window, -1, 0);
+    SDL_Texture *texture = SDL_CreateTextureFromSurface(r, g_image);
+    SDL_RenderCopy(r, texture, nullptr, nullptr);
+    SDL_RenderPresent(r);
+    SDL_DestroyTexture(texture);
+    SDL_DestroyRenderer(r);
+    return true;
+  }
   SDL_FillRect(ws, NULL, SDL_MapRGB(ws->format, 0x00, 0x00, 0x00));
   if (g_image) {
     SDL_BlitSurface(g_image, NULL, ws, NULL);

from wuffs.

pjanx avatar pjanx commented on May 3, 2024

Feel free to close my issue once SDL works (just handle the failing SDL_GetWindowSurface), XCB rejected my attempts at debugging, and it's a horrible mess all around.

from wuffs.

nigeltao avatar nigeltao commented on May 3, 2024

Thanks for the bug report. Can you copy/paste the output of xdpyinfo?

Or, if that's too large, perhaps xdpyinfo | head -n 100?

System: Arch Linux, X11 with DefaultDepth 30

Just double-checking... is it really 30, not 32?

from wuffs.

pjanx avatar pjanx commented on May 3, 2024

It's just 10-bit colour. xdpyinfo.log doesn't contain alpha, so it isn't all that useful. This information is in pixelformats, not visuals.

Here is an XGB image viewer for a known-to-work approach, with XRender scaling, although it's set up to require the depth--you could have two serialising functions, one for ARGB32, another for RGB30.

from wuffs.

pjanx avatar pjanx commented on May 3, 2024

Coming back with randomly acquired knowledge. The display issue with the XCB demo is trivial: DecodeImageCallbacks::SelectPixfmt virtual-defaults to WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL, and the xcb_image_t is hardcoded to use s->root_depth and completely disregards the Visual. The XRender extension could be used to resolve the difference within X.org, similarly to the way it's used in that Go code--this is the simplest fix, together with the SDL workaround.

The crash is due to XCB_CONN_CLOSED_REQ_LEN_EXCEED:

maximum request size:  16777212 bytes

which leaves shared memory or incremental uploads. I thought BIG-REQUESTS would help, but no.

from wuffs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.