Frage

Cogl is a modern 3D graphics API with associated utility APIs designed to expose the features of 3D graphics hardware using a more object oriented design than OpenGL. The library has primarily been driven by the practical needs of Clutter but it is not tied to any one toolkit or even constrained to developing UI toolkits.

I have known the names of the common gnome libraries: cairo, pango, gtk, clutter and cogl for a long time, but recently i actually found out what the the libraries did. And the gnome documentation just told me that cogl can draw 3D in a more oo way, as shown in the quote above. But i find it hard to get started.

So How can i use cogl to draw a 3d cube in vala? Is it possible to animate the cube with clutter?

after looking through the internet, i couldn't find much. so i went to Github to look at some other peoples code but most of the code is made in C and seemed hard to read.

Can you show some examples or links to some examples written in vala? (can also be in C, but it makes it a little harder to read)

Thanks in advance

War es hilfreich?

Lösung 2

There are no CoglRenderer or CoglContext classes in the current vapi file for cogl-1.0.

I don't think you can even initialize Cogl without these which I can oddly only find in the documentation for cogl-2.0.

https://developer.gnome.org/cogl-2.0-experimental/stable/

Since there doesn't seem to be any Vala example at all and not many C examples, it's difficult to ask your question.

You should probably ask the Cogl mailing-list.

Edit: Since your question was about Clutter + Cogl there is indeed a Vala example here: https://wiki.gnome.org/Projects/Vala/ClutterSamples

Edit2: There is a Hello World tutorial using cogl-2.0 here: http://www.cogl3d.org/hello.html

As you can see Cogl is much more low level, when you use it standalone (without Clutter) you have to do a lot of setup code youreself (create drawing context, create a framebufer, create your drawing primitives, create a drawing pipeline, draw your primitives, etc.).

I don't know how Clutter works internally, but I think it does a lot of that work for you.

In any case it can't hurt if you learn some OpenGL first, since Cogl is a wrapper around OpenGL.

Edit3: This blog post shows how to integrate Cogle into Clutter: http://radialmind.blogspot.de/2012/02/cogl-or-opengl-for-3d-clutter-scenes.html

So this is how you jump out of the clutter loop: Define a custom actor. I did one in C, another example uses the C++ version. See also here. Define some properties that modify how things are rendered and some other general behavior. Override the paint loop. Save the matrices, define your own matrices, call your custom drawing code in 3D (has to be cogl!) and then put the matrices back as you found them.

Andere Tipps

I have written a few examples for Cogl in Vala.

Links:

Hope, it can be useful.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top