I'm a little confused about the relationship of the libraries listed above, here are what I think:
Cairo is a 2D graphic library, and GTK+ uses it to render widgets. Cario is low-level.
Cogl is a 3D graphic library based on OpenGL(or a fork? I don’t know), and Clutter is a 3D GUI toolkit based on Cogl.
If this is correct, will Clutter replace GTK+ someday?
And...
If you think there is a better place to ask this question or some books I should read first, please tell me! I'm self-learning programming for interest.
yes, Cairo is a high quality 2D drawing API, and GTK+ uses Cairo to draw itself.
Cogl is a GPU programming library that internally can use GL or GLES to access the graphics pipeline (though in theory it could as easily use DirectX on supported platforms).
Clutter uses Cogl for rendering, but it can also use Cairo for 2D elements.
Clutter will not replace GTK+: GTK+ is a very complex library that provides system integration, complex widgets, and other utility API that Clutter has no interest in providing.
the future is going to be a bit more gray than a black-and-white replacement.
Cairo can use Cogl to draw; Cogl will program the GPU pipeline, but Cairo will generate the geometry to be submitted, so you can have high quality 2D results. Cairo already can use GL directly, but Cogl has a better state tracking already.
Clutter can use GDK, the GTK+ windowing system API, to talk to the windowing system surfaces and get input events.
in the future, it's entirely possible that GTK+ will use Clutter internally as the base for its widgets - though that's still a work in progress.
in short, a diagram could be:
GPU <- [ [ Cogl + Cairo ] <- [ GDK + Clutter ] <- GTK+ ] <- application
Related
I am writing a game using SDL, but would like to use GTK+ for controls. I therefore need to embed an SDL_Surface into GTK+. How should I do this?
Edit
The game would be a tile-based transport simulator (like OpenTTD), but instead of using SDL to display the game UI (screenshot), I would use GTK+.
(I find OpenTTD's SDL-based GUI quite clumsy because it doesn't integrate with the OS and therefore doesn't support things like copy-paste, control with the arrow and tab keys, etc.)
Not knowing much about what you're currently trying to do I suspect that SDL and GTK+ may be overlapping quite a bit, so I'm not sure how useful would it be to use both at the same time.
When writing a game the purpose of any toolkit is usually to simply talk to the windowing system and to manage inputs as all the drawing is done using GL.
If you also plan to use GTK+ for controls I'd recommend to just use GTK+ and not mix the two.
With GTK+ the best way to use GL is to use the GtkGLArea widget which gives you a canvas where to draw using standard GL calls.
If instead you don't plan to use GL but you just want to draw in software, the right widget for that purpose would be GtkDrawingArea.
By joining the #gnome-games IRC channel on the irc.gnome.org server you may find people more knownledgeable that can guide you better than me. :)
I'd like to add a real-time graphical representation of what's going on behind some scala code. Just a black window of a given size where I can put colored pixels at random (x, y) points will do. That's exactly want I'll be doing, actually.
What library should I use? I want to stay as simple as possible, so as to avoid mixing in (say) a full-fledged game-writing library just for a quick and dirty way to place pixels on a canvas.
I'd just use the Java 2D Graphics API.
Scala has support for Java's Swing GUI API, see the scala.swing package in the Scala API documentation.
I want to draw a circle on the iPhone screen with Shadow and glossy effect.I am new to coreGraphics and OpenGL and dont really know the difference between the two.And which library is to be used when.
How can I draw following image in iPhone? any reference point to learn the appropriate library would be great.
have 3 of those images [1] [2] [3]
and a slider to control the glow.when you slide to change the glow it should go across all these, and furthermore some levels could have upto 50 circles.
OpenGL is not a library, it's an API that gives you a "no-frills" access to the graphics system. All it provides are graphics primitives (points, lines, triangles) that it places on the screen and rasterizes them applying colour, textures through mathematical formula and/or a program called shader.
Sure, what you want to draw can be drawn using OpenGL, but it will require several intermediate steps and an artistic understanding of how that image is created from drawing operations.
So to answer your question: The most simple approach is to store this kind of, well whatever it is, as a vector graphics (SVG), and draw it using a library that provides drawing from a file.
The choice between CoreGraphics and OpenGL should be based on what your application does primiarily: Is it rendering some 3D graphics, a custom written 3D engine maybe: Use OpenGL. If you're aiming to draw some kind of UI then CoreGraphics probably is the better choice.
you hear a lot about the advantages of OpenGL using the graphics processor directly and that that is the main advantage of using this technology over UIKit for example. But, if it's so much better to do it this way, why does UIKit not do it also?
UIKit builds on CoreAnimation which builds on OpenGL. Ever wondered who's doing all that scaling and alpha blending for you? It's the GPU, through OpenGL textures that contain rendered images of your views.
By the way, I think this is one of Apple's great technical achievements. Think about how smooth the experience is (for a developer as well as the user) and how much work it would take you do achieve something remotely similar.
To add a few more comments to what Steven wrote:
Every drawing on OS X and iOS is eventually done by Open GL. But there are ways drawing of a line can be done:
one is to render a line into a rasterized image by CPU, and then send the resulting rasterized image to the GPU to show it.
Another is to send the drawing command to the GPU so that the GPU draws it to a rasterized image.
Then, blending, animation etc work on the resulting rasterized image in the GPU.
If you use Open GL manually, 2. is what you usually do. I'm not sure which way UIKit drawing like UIBezierPath takes, but the OS X counterpart, AppKit, uses the method 1 unless you opt-in, which is called Quartz GL (which was called Quartz 2d extreme in the past):
Usually, AppKit draws things down to rasterized image, and send it to GPU.
With Quartz GL turned on, AppKit sends the drawing commands to GPU.
But Quartz GL is not turned on by default, due to various technical reasons, which are detailed in the (always fantastic) Ars Technica articles by John Siracusa. See the discussions here for 10.4 and another for 10.5.
Here is one official documentation on Quartz GL.
I'm having problems finding documentation to back up my assertion, but I believe the stack is something like:
UIKit -> Core Graphics -> Quartz2D -> OpenGL
So, UIKit, is in fact making use of OpenGL to accelerate UI widgets.
I have to develop an application "Behavior like an Tetris game".
I have never used "OpenGL" for the iPhone application developement.
Application is something like this
Red / green / blue square boxes drop from top
Red + Red + Red = Points & boxes disappears
same way user has to make combination & get points
Different levels are there.
There are three buttons Left, Right for movement & bottom for speedy fall
For this kind of application should I use open GL or NOT?
i.e. Is it possible to develop entire application with view & it's animation?
If yes then, will it be more complex as compare to open gl?
What is the advantage of using open GL?
(I know that it gives good 2d, 3d look )
(But here my question means - easy coding?)
(Or open gl is more complicated as compare to objective-c?)
(I am just asking because I am not aware of it)
Basically your options are:
Using OpenGL
Using Quartz
Using UIKit
OpenGL is a fairly complicated beast, but is by far the best way to squeeze performance out of the iPhone. Do you need it for a Tetris game, though? Almost certainly not.
Quartz is the toolkit used in Mac OS X and the iPhone to draw images and do image effects. Because I come from an OpenGL background in other languages, I find Quartz strange and frustrating. However, it is probably easier for someone who is new to both.
You can do everything here using UIKit, and it will definitely be much much easier than other options. The main disadvantage is that it's rather slow in comparison, but once again doing a Tetris-like game shouldn't matter at all.
Before you go with UIKit, though, I recommend just checking out something like Cocos 2D, which will give you the advantages of OpenGL without the headache of dealing with all of its inner workings.
From the tone of your question it looks like you're confusing what OpenGL is and isn't with regard to Objective-C.
OpenGL is a library written in the C programming language (to put it simplistically) that excels at rendering shapes (especially 3D shapes) for display on a screen. It doesn't replace Objective-C inside your program, it merely assists you in drawing the shapes. If you don't use OpenGL, you'll need to write some sort of drawing/rendering code in your NSView (or subclass) to render the blocks. By using OpenGL, you will be provided a lot of helpful C methods for drawing shapes, which otherwise you'll have to implement yourself. On top of that OpenGL has thousands of man hours worth of drawing optimizations that you can take advantage of if you use it rather than trying to implement shape rendering yourself.
Having said that, OpenGL isn't all sunshine and roses. It works like a state machine and has its own assumptions about the way it will be used (like any API). Just because you know C and Objective-C doesn't mean that using OpenGL will be trivial. If you've never written any OpenGL code, I suggest you look into a reference like the venerable Red Book.
The thing to keep in mind is that OpenGL is not a language until itself (ignoring the OpenGL shading language). Its merely a set of C functions to aid you in rendering graphics.
You may well want to ask as well on http://iphonegamedev.stackexchange.com/, the new Stack Overflow variant just for iPhone gaming.
To learn & understand what you need.
Please go through following link.
it includes all necessary links for all kind of resources that you needed.
http://maniacdev.com/2009/04/8-great-resources-for-learning-iphone-opengl-es/
Edit :
After reading your question properly ( actually my question - By r & d I found solution).
I think - you need to develop a 2d application.
Go for the following link. Best option for 2d animation.
http://code.google.com/p/cocos2d-iphone/
Don't forget to visit following link, if you needed sample codes.
http://monoclestudios.com/cocos2d_whitepaper.html