The simple direct media layer (SDL) provides a layer that allows the same code to compile into a consistent multiplatform application. However for 3D graphics SDL uses OpenGL. OpenGL has a known history for being inconsistent across platforms, even on just the PC platforms (Windows, Linux and Mac) so my question is does this still apply when using OpenGL with SDL? Or has SDL provided a solution for this inconsistency?
Does this still apply when using OpenGL with SDL?
Yes.
Or has SDL provided a solution for this inconsistency?
No. Closest they have is the 2D accelerated rendering API which wraps OpenGL/OpenGL ES/DirectX as necessary.
Related
I am trying to choose between GTK+3 GdkVulkanContext and Qt QVulkanWindowRenderer for a project that requires the use of Vulkan for rendering graphics. What are the key differences between the two frameworks in terms of their support for and integration with Vulkan (GTK+3 will be manually translated in c++)? Are there any significant advantages or disadvantages to using one over the other in this context?
Does SDL2 have the capability to render things in 3D (i.e. make cubes, spheres, etc.) without the use of OpenGL, or does it only have 2D capabilities?
Your question would be better off on GameDev Stackexchange but to simply answer your question: SDL2 itself has no capabilities to render 3D objects. This is also stated in SDLs about page:
Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D
SDL provides some functions to help you ease the use of OpenGL, but you'll have to learn and use OpenGL to allow rendering 2D and 3D vector graphics.
A good tutorial that I'd recommend on the basics of SDL is this site. It only has some chapters related to the use of OpenGL, but if you haven't used SDL much, this is a great start.
Here's what the wiki has to say:
2D Accelerated Rendering
For advanced functionality like particle effects or actual 3D you should use SDL's OpenGL/Direct3D support or one of the many available 3D engines.
SDL does not aim to provide a 3D API, but gives you some support for other well-known APIs like OpenGL and Direct3D.
Note that SDL2 also provides Vulkan support.
I decided to do some OpenGL programming on OSX. I created a small NSOpenGLView class in order for me to get an OpenGL view in cocoa.
From there my plan was to switch to C++ and create an object model to draw shapes. Having no interest in reinventing the wheel I decided to use glutWireSphere to represent my sphere class.
Interestingly XCode throws a deprecation warning for ~90% of all the glu and glut functions. Including the sphere function.
Is there an Apple library that provides primitives similar to Glut? Am I missing something? Is there a current HowTo for OpenGL programming on OSX (OpenGL >= 3.2)? I'm currently looking through the OpenGL Programming Guide for Mac but that doesn't seem to cover it. Googling it mostly returns IOS or old results.
Note: I don't want to force the compilation to 10.8. And I don't necessarily want to link external libraries like GLFW.
You might want to check out SceneKit if you can use 10.9+. It's a native Cocoa framework specifically designed for dealing with 3D rendering.
From the docs:
'Scene Kit is a 3D-rendering Objective-C framework that combines a
high-performance rendering engine with a high-level, descriptive API.
Scene Kit supports the import, manipulation, and rendering of 3D
assets without requiring the exact steps to render a scene the way
OpenGL does.'
In particular the SCNSphere class is what you'll be looking for.
And here's a nice scene kit intro by Big Nerd Ranch:
SceneKit in Mountain Lion
However, one thing to consider is that you'll end up with code that is not portable to other platforms as SceneKit is native to OS X (and eventually iOS). Frameworks like OpenGL, Ogre, Irrlicht on the other hand support many different desktop and mobile platforms.
I am looking for the best native library that is similar to three.js in its structure and simplicity but is also extensible enough to support glsl shaders.
Requirements:
Open Source or very well documented for possible extension/enhancement
Allows commercial derivatives/use
Can either be wrapped in a physics library or easily paired with one.
Fast enough to support modern game graphics.
OpenGL or Mantle based. (I don't want to be stuck with windows.)
Windows support
Supports a system similar to three.js local/world coordinate system.
Raycasting support for doing collision detection.
Huge Bonus:
Supports Linux and OSX as well as windows.
I am looking for the closest match to Three.js as possible that is written in C++ similar to three.cpp but has completed functionality and is less beta/alpha status.
Have you tried Magnum ?
http://mosra.cz/blog/download-magnum.php
Supported platforms
Graphics APIs:
OpenGL 2.1 through 4.4, core profile functionality and modern extensions
OpenGL ES 2.0, 3.0 and extensions to match desktop OpenGL functionality
WebGL 1.0 and extensions to match desktop OpenGL functionality
Platforms:
Linux and embedded Linux (natively using GLX/EGL and Xlib or through GLUT or SDL2 toolkit)
Windows (through GLUT or SDL2 toolkit)
OS X (through SDL2 toolkit, thanks to Miguel Martin)
Google Chrome (through Native Client, both newlib and glibc toolchains are supported)
HTML5/JavaScript (through Emscripten)
Threejs actually does support glsl shaders. You can use THREE.ShaderMaterial class to create your own shader then pass your vertexShader and fragmentShader to it.
Another option is to program directly in WebGL. ThreeJS is built on top of WebGL. The only reason why I decided to use ThreeJS was to avoid writing glsl shaders since WebGL doesn't have materials and forces you to write your own glsl shaders, so if that's what you want you could go directly to WebGL. WebGL is more low level than Threejs.
If you don't like javascript, then you could use JogAmp's Ardor3D which is in Java. It's a 3D scenegraph renderer just like Threejs but in Java.
All of the above options have super fast game quality rendering performance.
Is there a browser engine that may use OpenGL as backend or adpater library to provide such? So that a web page can be rendered using a usual programmable pipeline of OpenGL.
I thought most browsers would use well known 2D frameworks that maybe would be provided with adapters by 3rd party, but just cant figure out if for example Webkit could work from a single mainstream 2D library.
Recent versions of WebKit will use the GPU accelerated graphics APIs provided by the OS if available. Direct2D on Windows and OpenVG on other systems if available. That being said it would be perfectly possible to implement a OpenGL backend to WebKit.
I suggest you look at current developments regarding Wayland on Linux, which will require some major changes in the way applications to their graphics business. There should be already substancial work on the WebKit-GTK+ bindings to make it use EGL created graphics surfaces. It is trivial to bind such EGL surfaces as OpenGL texture.
OpenGLES is not a 2D library, but I presume you meant frameworks that use OpenGLES for primarily 2D texturing. Chromium is one of the good examples of how OpenGL ES2 can be used for this, it accelerates canvas, CSS, and composition among other things using OpenGLES2.
http://www.chromium.org/developers/design-documents/gpu-accelerated-compositing-in-chrome
Until recently, the cairo-directfb backend for Webkit used to be quite popular, but now with every SOC having GLES2 support, things have changed. See for example below:
http://luorhino2006.wordpress.com/2010/04/02/build-webkit-over-pango-cairo-and-directfb-from-scratch/