6 ms·
There are no cross-platform APIs for something as simple as "blit a bunch of pixels to the screen" anyway, so WASI is pretty much free to define its own. I'm s
by flohofwoe 7y ago
There are no cross-platform APIs for something as simple as "blit a bunch of pixels to the screen" anyway, so WASI is pretty much free to define its own.
I'm sure over time, and if desired, WASI will get a set of higher level platform-wrapper APIs for rendering, audio, input and networking, but the requirements are somewhat different from traditional "native" APIs, for instance, compatibility with web APIs is useful. So we'll probably see the WebGPU API for 3D rendering, instead of Vulkan, D3D12 or Metal.
- pjmlp 7y agoSDL comes to mind.
- mysterydip 7y agoWould the Java APIs be something to copy? I believe they have had cross-platform graphics classes for a long time.
- zozbot234 7y agoUm, I can think of some folks who got in a bit of legal trouble for (allegedly) ripping off the Java API. I don't think you'd want to do that!
- andybak 7y agoThis comment has made me sad about that stupid, stupid verdict all over again.
- usrusr 7y agoJava has been immensely successful and carefully modernized for decades, but none of that is true for its graphics APIs.
- pjmlp 7y agoIt looks quite modern to me, specially given what some people are fighting to get into ISO C++, or what other languages offer on their standard libraries.
- Jasper_ 7y ago... don't remind me of that proposal, lol. I think it's finally dead, and admitted it was a complete and utter failure of LEWG to let it get as far as it did [0]. Unfortunately, we now have "diet graphics", which consists of stuffing WebKit into C++ and calling it a day [1], so, looking forward to where that goes! [2] [0] https://www.reddit.com/r/cpp/comments/89q6wr/sg13_2d_graphics_why_it_failed/ https://www.reddit.com/r/cpp/comments/89q6wr/sg13_2d_graphic... [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1108r0.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p110... [2] Hopefully into the bin.
- stefan_ 7y agoI don't understand, WASM can't use canvas? Because if you "blit a bunch of pixels to the screen", you don't care about performance regardless.
- flohofwoe 7y agoA complex browser API like canvas requires much more effort to "emulate" in WASI than a simple 2D framebuffer access. I think emulating the Linux framebuffer device is the right first step. PS: I think there's some confusion about WASM running in browsers, vs WASM running on top of WASI. WASI is all about running WASM outside the browser: https://wasi.dev/ https://wasi.dev/
- zozbot234 7y agoThe Linux framebuffer device is a legacy thing which doesn't mesh with the way modern graphics chipsets work. GPUs today are practically glorified sprites engines where a "framebuffer", a "texture" and a "sprite" are essentially one and the same in implementation, and new entities can be created by compositing ("blitting") existing ones with arbitrary 3D transformations, alpha-blending, anti-aliasing etc. You don't want to be limited to a single frame-buffer with pixel-level access and everything being drawn/blitted by software, that would be dog-slow.
- flohofwoe 7y agoIt's not about performance but about convenience. Having a way to plot single pixels with the CPU without a lot of boilerplate code to setup a 3D API context, creating textures, vertex buffers, shaders etc etc is a good thing to have in many situations. That this is not a good way for doing more complex rendering tasks seems quite obvious (e.g. in the long run this cannot be the only API for covering all sorts of rendering, but it happens to be a good sweet spot for getting anything on screen at all, and not having to deal with an overly complex rendering API just to get some 2D image data rendered).
- zozbot234 7y ago
- LockAndLol 7y agoWhat about OpenGL?
- flohofwoe 7y agoOpenGL is on the way out, and for rendering 2D image data it requires too much setup code (need to create the GL context, a swap chain, a texture, and (unless GL 1.x is used) a vertex buffer, shader and setting up tons of render state). For 3D rendering, WebGPU would be the better option to support in WASI because it has standalone native implementations: https://dawn.googlesource.com/dawn https://dawn.googlesource.com/dawn https://github.com/gfx-rs/wgpu https://github.com/gfx-rs/wgpu But for blitting CPU-generated 2D image data to the screen WebGPU is also sort of overkill (of course it would be possible to create a much simplified wrapper library in WASM).
- gdxhyrd 7y agoNo, OpenGL is not "on the way out". Please back up your claims.
- Godel_unicode 7y agoOpenGL is certainly used by a number of creative apps like Photoshop, but you can't deny that the number of games released with OpenGL is down significantly since say 2010.
- gdxhyrd 7y agoA lot of games and apps are being released using OpenGL today. Then there is WebGL and OpenGL ES, widely used everywhere too. So, no, it is not going anywhere. In fact, Khronos themselves have said so.
- Godel_unicode 7y agoI didn't say that there were no OpenGL games being released in 2019/2020 but that the ratio is definitely skewing away from OpenGL. "A lot of games" seems like a stretch compared with what the numbers used to be. Also I think it's obvious but I'll say it anyway; it's not up to khronos it's up to developers. It doesn't matter if they continue to support OpenGL if developers move to some combination of dx11/12, Vulkan, and Metal. WebGL and OpenGL ES aren't OpenGL. Their uptake or lack thereof in other arenas is orthogonal to whether people are moving away from OpenGL for game development.
- boomlinde 7y ago> There are no cross-platform APIs for something as simple as "blit a bunch of pixels to the screen" anyway SDL? Has ports for more obscure platforms, too
- grawprog 7y agoYup my first though and drawing a pixel with SDL is pretty easy comparatively. SDL_Window *window; SDL_Renderer *renderer; SDL_CreateWindowAndRenderer(800, 600, 0, &window, &renderer); SDL_RenderDrawPoint(renderer, 400, 300); //Renders on middle of screen. SDL_RenderPresent(renderer); There's also SDL bindings in a bunch of languages, a few official ones here https://www.libsdl.org/languages.php https://www.libsdl.org/languages.php
- earenndil 7y agoAgreed. SDL2 is one of the few libraries I've used that I can honestly say is well-designed.
- azakai 7y ago> There are no cross-platform APIs for something as simple as "blit a bunch of pixels to the screen" anyway, so WASI is pretty much free to define its own. [..] compatibility with web APIs is useful Personally I think Web compatibility is so useful that wasm off the Web should use Web APIs, instead of the direction WASI is going. WASI is an effort to create a new OS API layer from scratch, without the baggage of POSIX or the Web or such. That's definitely interesting, and may be a big deal in the long run, but it has risks (it will take a lot longer, in particular) and it has downsides for the Web (which is personally the platform I care most about).