Results 1 to 7 of 7

Thread: ClanLib and OpenGL

  1. #1

    Default ClanLib and OpenGL

    Hi,

    I am trying to understand how Clanlib and OpenGL work together - is clanlib like a version of GLUT for openGl? is it a whole engine?
    What should I expect to do with it, and how should I treat it?

    I have looked at the examples, of course, but I am still rather confused - what do I do with it?

    I know OpenGL quite well, and also worked with ClanLib sprites and such for quite some time now, and I love it - but I am not sure how to combine the two.

    Any advice would be appreciated,
    Thanks,
    Daniel

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Humm, I thought there was OpenGL documentation in ClanLib.

    Looking at http://clanlib.org/wiki/MainDocs:OpenGL "Not written yet. Why don't you do it? :-) ", I guess not!

    I have not used GLUT, so I can't describe differences. Maybe someone else can?

    Anyway...

    You can think of ClanLib as a C++ wrapper to OpenGL. A lot of classes used in ClanLib were written to contain OpenGL functionality.

    However officially ClanLib is not an C++ OpenGL wrapper. If it was, it would be too difficult to maintain other display targets (for example, clanSWRender)

    You can use OpenGL directly if you wish. Although personally I have never had to

    ClanLib clanGL target contains all the direct OpenGL function calls for OpenGL 3.2.
    These are called using the "cl" prefix, instead of the "gl" prefix.
    See - http://clanlib.org/docs/clanlib-2.2/...L__System.html

    The CustomGL does this. Note, the OpenGL 1.x target (clanGL1) uses the "cl1" prefix instead of the "cl" prefix.

    If you use multiple windows and using manual OpenGL, to select the active opengl context, use CL_OpenGL::set_active(gc)

    ClanLib CL_Sprites and CL_Images are specially designed to be very fast, batch drawing images.

    There is more to explain, but I have not got the time today.

  3. #3

    Default Thanks!

    Thanks for the response!

    I still, however, fail to really understand the relationship between clanlib and openGL.

    I do understand that clanlib abstracts some of the interfaces with openGL (creating context, initialization etc...) - but when it comes to start drawing things on screen - what does clanlib do?

    I know I can use "custom" openGL and just draw everything myself, but then - why would I use clanlib? I am sure clanlib can help with more, but I am not sure how...

    Thanks again!
    Daniel

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Take CL_Image for example:
    1) It loads and decodes an image, uploading to an OpenGL texture (via CL_Texture)
    2) When drawing via CL_Image API, ClanLib collects all calls (via CL_RenderBatcher) until there is a state change in the CL_GraphicContext. Then it batch draws the images in a single opengl call.

    For CL_Image, that basically is it.

    There is more detail, for example
    1) Internally, If the image is already loaded (even in a differerent OpenGL context), reuse the texture via CL_SharedGCData
    2) Ability to use multiple images in the same picture.
    3) Internally, the render batcher drawing has a custom OpenGL shader that allows 3 OpenGL source textures to be used in the same batch. Useful drawing images and CL_Fonts

    CL_Fonts, CL_Sprites also have been optimised like this.

    CL_Texture is a raw OpenGL wrapper to the image.

    If you already use OpenGL and already has custom optimisations in your code. There is no advantage or disadvantages in using clanDisplay

    With clanDisplay you also get: CL_Fonts and Keyboard/Mouse input.

  5. #5

    Default Thanks again!

    I understand that OpenGL is the backend of a lot of the 2D graphics in Clanlib - but say I would want to use clanlib for some 3D graphics - how can this help me?

    Does using CL_Texture, for example, gives me any advantage over just loading textures my self?
    Can ClanLib help me with creating geometry? transforms?

    Thanks again, it is great to see there is someone to ask here, makes me want to use clanlib more :-)
    Daniel

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Quote Originally Posted by zdaniez View Post
    I understand that OpenGL is the backend of a lot of the 2D graphics in Clanlib - but say I would want to use clanlib for some 3D graphics - how can this help me?

    Does using CL_Texture, for example, gives me any advantage over just loading textures my self?
    Can ClanLib help me with creating geometry? transforms?

    Thanks again, it is great to see there is someone to ask here, makes me want to use clanlib more :-)
    Daniel
    Maybe Ogre would be better for you?

    CL_Texture advantage is that you don't have to code it yourself. It does not contain any magic. It just makes OpenGL calls directly.

    Creating geometry is out of scope of ClanLib. I personally was going to create an example that contains code to do it, but there was no point. That's what applications such as Blender can do. So I created a simple Collada loader instead.

    Of course ClanLib contains all the 3D math functions that you require (from line intersection to quaternions)

    ClanLib can do 3D without any problem. (See the 3D examples). But geometry loaders probably will never exist in the API.

    There are 4 reasons for this:
    1) Ogre exists
    2) ClanLib bloat
    3) It's very difficult to create an API that everyone likes. There are different methods of doing 3D, depending on the type of application that you are writing. For example: euler angle vs quaternions or XYZ rotation order us YXZ rotation order.
    4) It's easier to create an example that the programmer can adapt for there needs.

  7. #7

    Default Thanks again

    Thanks for all the help and pointers - hope to have something up and running soon...

    Daniel

Similar Threads

  1. ClanLib can work with OpenGL ES?
    By falsinfab in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 06-15-2010, 01:05 PM
  2. How to use OpenGl in ClanLib 2
    By xenus in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 09-16-2009, 02:15 PM
  3. ClanLib 0.9 OpenGL Fonts
    By rombust in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 09-05-2008, 11:45 AM
  4. OpenGL 3.0 and ClanLib 0.9
    By Judas in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 08-13-2008, 04:52 AM
  5. Little example ClanLib+OpenGL
    By rinsukaze in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 05-13-2008, 07:15 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •