Direct2D Equivalent for IOS OSX development - c++

I am developing a user interface for my application.... most of my application is portable as is written in c++ but today I started thinking about the UI. Which is currently written in Direct2D. I was wondering if there was an equivalent for developing a UI in IOS(Ipad), and OSX(MAC)?
Something high level enough that I could draw rectangles and circles, but also low level enough that is not as slow as GDI.
Thanks in advance.
PS. I DON'T want comparing which are better or worse, I just want to know what options I have.

CoreAnimation is a GPU-accelerated framework. Individual views are cached on the GPU. You can then apply composition arbitrary transforms to them. Such transforms are applied by the GPU to the cached image. So you can use CoreGraphics to draw a circle, rectangle or whatever, have CoreAnimation store that bitmap on the GPU and then transform that.
Also from the first-party frameworks, Sprite Kit provides a game-oriented framework that includes game-style (ie, accelerated write-once read-many 'sprites') drawing alongside physics/etc.
OpenGL ES is also fully supported. You can assume 2.0 is always available as it was introduced on the 3GS and Apple no longer accepts binaries for older devices. 3.0 is also available on the latest iPhone. That's obviously quite a bit lower level than Direct2D but Apple supplies GLKit which allows you to upload images trivially and to emulate the old fixed-functionality pipeline with just a few simple calls.
Out in the third-party world I guess the main thing people are going to suggest is Cocos2d but at this point it's already playing catch-up to Sprite Kit.
Of those, CoreAnimation, OpenGL and Cocos2D span iOS and OS X with some minor differences, Sprite Kit is already available on iOS and will turn up in the next OS X Mavericks.

Start with Cocoa (OSX) and Cocoa Touch (iOS). In apps made with those you can use Core Graphics which seems like a good fit for your needs, or OpenGL which is probably overkill. Of course there are many 3rd party libraries you can use, Cocos2d as Petesh mentioned is one of them.

Related

Software and Hardware rendering in SDL2/SFML2

First off, I'm relatively new to this. I'm looking forward to picking up both SDL2 as well as SFML2 libraries for game dev. (and other stuff).
Now I know for a fact that both SDL2 and SFML2 are capable of creating OpenGL enabled contexts, through which OpenGL graphics programming may be done.
But online, I've read discussions wherein people said something to the effect of "SDL 1.2 is software accelerated, SDL2 and SFML2 are hardware accelerated by default". I know that software rendering is graphics using CPU alone. While Hardware rendering uses graphics cards/pipeline.
So my question is, with regards to these game libraries:
Part 1: when someone says one is software/hardware acc.by default, what does he mean? Is it that (my guess) if say SFML2 is hardware acc. by default, even basic 2d graphics are done by it using hardware rendering as the backend pipeline to do it, even if I didn't explicitly do any hardware-rendering programming in the code?
Part 2: And if that is true, is there any option within these libraries to set that to software acceleration/rendering?
Part 3: Which of these 2 libraries (SDL2 vs SFML2) has better overall performance/speed?
Thanks in advance for any answer and apologies if you found the question dumb.
Cannot say anything about SFML (but almost sure things are very close), but for SDL it is as you say. In SDL1 2d drawing implemented as blitting directly on display surface, and then sending this surface to display - so mostly software (although minor hw acceleration is still possible). SDL2 have SDL_Renderer and textures (which are GPU-side images or render targets) and any basic drawing that uses renderer may be accelerated by one or another backend. Which backend will be chosen depends on system your program runs and user settings - e.g. it would default to opengl for linux, d3d for windows (but still can use opengl), opengles for android/ios, etc..
You can use software renderer either by explicitly calling SDL_CreateSoftwareRenderer, or hint SDL to use software driver, or even override it by setting SDL_RENDER_DRIVER environment variable.
If you intend to use opengl for 3d graphics - then you just ignore all that and create window with opengl context as usual, and never use SDL_Renderer.

Glut/Glu alternatives on OSX 10.9 for drawing primitives like spheres

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.

browser engine with OpenGL backend

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/

Does stage3d use OpenGL? or Direct3D when on Windows

WebGl is based on OpelGL ES 2.0.
Is it correct to say that Stage3d is also based OpenGL? I mean does it call OpenGL functions? Or ot calles Direct3D when runs on Windows?
If no, could you explain me, what API does Stage3d use for hardware acceleration?
The accepted answer is incorrect unfortunately. Stage 3D uses:
DirectX on Windows systems
OpenGL on OSX systems
OpenGL ES on mobile
Software Renderer when no hardware acceleration is available. (Due to
older hardware or no hardware at all.)
Please see: http://www.slideshare.net/danielfreeman779/adobe-air-stage3d-and-agal
Good day, Stage3D isn't based on anything, it may share similar methodology/terminology. It is another rendering pipeline, this is why Adobe is soo pumped about it.
Have a look at this: http://www.adobe.com/devnet/flashplayer/articles/how-stage3d-works.html
You can skip down to this heading "Comparing the advantages and restrictions of working with Stage3D" to get right down to it.
Also, take a peak at this: http://www.adobe.com/devnet/flashplayer/stage3d.html, excerpt:
The Stage3D APIs in Flash Player and Adobe AIR offer a fully
hardware-accelerated architecture that brings stunning visuals across
desktop browsers and iOS and Android apps enabling advanced 2D and 3D
capabilities. This set of low-level GPU-accelerated APIs provide
developers with the flexibility to leverage GPU hardware acceleration
for significant performance gains in video game development, whether
you’re using cutting-edge 3D game engines or the intuitive, lightning
fast Starling 2D framework that powers Angry Birds.

What are the actual SDL2 hardware requirements?

I just can't find them anywhere. The most important part for me is the hardware acceleration, and I have no idea if there is a performance or openGL version compatibility requirement that the video card has to follow.
The minimum system requirements will depend alot more on the application that you are writing than what SDL2 does.
If you just create a standard window and render SDL will use what it can find and what it thinks is best either OpenGL, OpenGL ES, Direct3D or use the old style software rendering for machines that can't do any of the other. So if a computer can support an OS that SDL runs on then you will almost always (I just said almost since there can possible be exceptions) be able to run these type of apps (Video card not a requirement, but having one will greatly increase programs drawing speed).
You can also be creating a OpenGL application directly and then it depends on what type of context you are making what the video card has to support.
You can find most of the information here: http://wiki.libsdl.org/moin.fcg/MigrationGuide
under the Video section. It's actually how to port from 1.2 to 2.0 , but it explains the new Video Pipeline pretty well.
Hope thats what you were looking for.