Results 1 to 7 of 7

Thread: Using dlopen() with OpenGL

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

    Default Using dlopen() with OpenGL

    It has been suggested to use dlopen() on OpenGL. (linux)

    Well, we will probably use it at some time, when someone implements it fully with GL and GL1 targets.

    Just a note of information: http://www.xfree86.org/4.8.0/DRI11.html

    See - 11.5. libGL.so and dlopen()

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

    Default

    I have created a patch to use dlopen for linux

    Please can someone check and comment on it.

    I am not sure it is the best approach.

    It seems a bit hacky at the moment.

    Unless I should apply it, and someone tidy it, as a later date

    ah. almost forgot. I created it for 2.1 svn, but it should work with 2.2
    Attached Files Attached Files

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

    Default

    Okay.

    I have applied the patch to GL1 target as well as the GL target, committed to both ClanLib 2.1 SVN and ClanLib 2.2 SVN

    Hopefully now OpenGL on ClanLib will be a lot more stable! ... maybe!

    There is one question though...

    We load "glXGetProcAddressARB" using dlopen in CL_OpenGLWindowProvider_GLX
    into the CL_GL_GLXFunctions class

    Now, when binding occurs:

    CL_OpenGL::get_proc_address() calls CL_OpenGLGraphicContextProvider::get_proc_address( )
    that runs:
    Code:
    const CL_GL_RenderWindowProvider_GLX *wptr = dynamic_cast<const CL_GL_RenderWindowProvider_GLX *> (render_window);
    if (wptr == NULL)
    	return NULL;
    
    return wptr->get_proc_address(function_name);
    that calls:

    Code:
    CL_ProcAddress *CL_GL_RenderWindowProvider_GLX::get_proc_address(const CL_String8& function_name) const
    {
    if (window.glx.glXGetProcAddressARB)
    	return window.glx.glXGetProcAddressARB((GLubyte*)function_name.c_str());
    if (window.glx.glXGetProcAddress)
    	return window.glx.glXGetProcAddress((GLubyte*)function_name.c_str());
    return NULL;
    }
    I thought it would be better to expose the glx functions (CL_GL_GLXFunctions) to the API (to opengl_wrap.h) , but it's not simple.

    With reference to the CL_RenderWindowProvider class ( http://clanlib.org/docs/clanlib-2.0....wProvider.html )

    This causes difficulty. Because I want CL_OpenGLWindowProvider_GLX to own the functions. I would need to do a lot of dynamic casting from CL_RenderWindowProvider so CL_OpenGL can see it.

    Also for the GL1 target: (in CL_GL1GraphicContextProvider::get_proc_address()
    we have:
    Code:
    // FIXME: This is very messy
    const CL_GL1_RenderWindowProvider_GLX *wptr = dynamic_cast<const CL_GL1_RenderWindowProvider_GLX *> (render_window);
    if (wptr)
    	return wptr->get_proc_address(function_name);
    
    const CL_RenderWindowProvider_GLX_PBuffer *pptr = dynamic_cast<const CL_RenderWindowProvider_GLX_PBuffer *> (render_window);
    if (pptr)
    	return pptr->get_proc_address(function_name);
    
    return NULL;
    This can't be right!
    Last edited by rombust; 11-20-2009 at 10:58 AM.

  4. #4

    Default

    Quote Originally Posted by rombust View Post
    I have created a patch to use dlopen for linux

    Please can someone check and comment on it.

    I am not sure it is the best approach.

    It seems a bit hacky at the moment.

    Unless I should apply it, and someone tidy it, as a later date

    ah. almost forgot. I created it for 2.1 svn, but it should work with 2.2
    Hi! Sorry, i never used svn, i tried to make a repository, and then type: patch /home/path/to/repo/ /home/path/to/patch/dlopen_patch.txt
    but something didn't work... Can you upload opengl_window_provider_glx.cpp, opengl_window_provider_glx.h and opengl_graphic_context_provider.h ?
    Thanks!

    Koli

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

    Default

    To use svn on linux:

    You have 2 choices (that I know of)

    svn checkout ( http://svnbook.red-bean.com/en/1.0/re04.html )
    (then svn update to update it, if required)

    or

    Use kdesvn (Use menu option "Subversion/General/Checkout a repository")

    With the url of: svn://esoteric.clanlib.org/ClanLib/Development/ClanLib-2.1

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

    Default

    If not, I may do an beta release, for users in this forum to test.

    Hopefully some time before the end of the year 2.1.1 will be released.

    So far, ClanLib 2.1.1 modifications include:
    1) Using dlopen() for linux. This is so your application can use the libgl.so local on the machine it runs on (so it uses the configured driver on the machine, not the driver that the application was compiled with)
    2) Removed XF86VidMode on linux (caused problems on various distros and is "considered sort of deprecated by upstream xorg" ) .As far as I know, noone used CL_DisplayWindowMode().
    3) Some Minor fixes
    4) Added CL_ColorHSV, CL_ColorHSL classes
    5) Added a ColorWheel example (using HSV, HSL) and a Blend example (using all the OpenGL blending options that clanlib supports)
    6) The Linux .tgz package, includes a free GUI theme (GUIThemeBasic) for use with the clanlib examples (or your application). The Microsoft windows themes for the linux package will be removed.

  7. #7

Similar Threads

  1. OpenGL ES?
    By NovaLaw in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 10-19-2009, 07:20 PM
  2. Requires OpenGL 2.0
    By yaim0310 in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 10-11-2009, 03:36 PM
  3. 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
  4. OpenGL 2.0
    By madmark in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 06-17-2009, 04:21 PM
  5. SDL V's OPENGL
    By babyvegas in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 07-30-2008, 10:07 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
  •