Results 1 to 19 of 19

Thread: Corrupted images and random crashes with ClanLib 0.8 on Ubuntu Feisty

  1. #1

    Unhappy Corrupted images and random crashes with ClanLib 0.8 on Ubuntu Feisty

    Hi everyone! I have a little (!!!) problem with ClanLib 0.8. For the records, I'm running on Ubuntu 7.04 (Feisty), and I've been developing on this machine for quite a while now (including with SDL and OpenGL). So it should not be a newbie problem... I think...

    When I compile any application with ClanLib (even the Basic2D example!), I get corrupted loaded images, and a crash now and then...

    I'm compiling without problem ClanLib 0.8, first from the website-supplied .tgz, then from the SVN version, and I still have the problem. I tried with the 0.65ish version that comes in the Ubuntu repo, and all seems fine (it's now completely uninstalled, by the way). The problem only seems to occur with the 0.8 version. I know the application links with the correct ClanLib libraries (at least, that's what ldd tells me).

    Is there any pre-requisite (e.g. dependency version) that's not checked by the ./configure script? Is there something I forgot to do? I've done the standard configure-make-checkinstall for ClanLib, and make for the example...

    I'm really clueless. I'll be thankful to anyone who can help me.

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Bergen, Norway


    Could it be faulty OpenGL drivers on your system?

  3. #3


    I'd be suprised, since I can develop in "normal OpenGL", and all works fine. Also, the display seems OK for the lines and shapes drawing; only the loaded pictures are problematic.

  4. #4
    ClanLib Developer
    Join Date
    May 2007


    Try the 0.9 svn, it's "./configure" performs more library checks than 0.8.

    I use feisty ubtuntu (and nvidia), both the Basic2d examples on 0.8 and 0.9 work on my machine.

    I assume that you have performed:
    ./configure --enable-debug
    make clean
    sudo make install

    Also ensure that /etc/ contains the clanlib library directory. (Remember to run ldconfig afterwards)

  5. #5


    Ok, I did try with the 0.9 svn version. The built went well, without a problem.

    $ ./configure --enable-debug --disable-docs
    The following modules will be built:
                         clanGL = yes
                        clanSDL = no
                        clanApp = yes
                   clanDatabase = yes
                     clanRegExp = no
                      clanMySQL = no
                     clanSqlite = no
                        clanGUI = yes
                       clanCore = yes
                      clanSound = yes
                    clanNetwork = yes
                    clanDisplay = yes
                     clanMikmod = yes
                     clanVorbis = yes
            Build Documentation = no
                    Debug Build = yes
    However, the Basic2d example won't even start:
    $ ./basic2d 
    X Error of failed request:  BadMatch (invalid parameter attributes)
      Major opcode of failed request:  42 (X_SetInputFocus)
      Serial number of failed request:  57
      Current serial number in output stream:  58
    Just in case the problem is with OpenGL (even though the problem now seems to be with some kind of input-thingie), I output my glxinfo stuff:
    $ glxinfo
    name of display: :0.0
    display: :0  screen: 0
    direct rendering: Yes
    server glx vendor string: SGI
    server glx version string: 1.2
    server glx extensions:
        GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, 
        GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, 
        GLX_OML_swap_method, GLX_SGI_make_current_read, GLX_SGI_swap_control, 
        GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_visual_select_group
    client glx vendor string: SGI
    client glx version string: 1.4
    client glx extensions:
        GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context, 
        GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_allocate_memory, 
        GLX_MESA_copy_sub_buffer, GLX_MESA_swap_control, 
        GLX_MESA_swap_frame_usage, GLX_OML_swap_method, GLX_OML_sync_control, 
        GLX_SGI_make_current_read, GLX_SGI_swap_control, GLX_SGI_video_sync, 
        GLX_SGIS_multisample, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, 
        GLX_SGIX_visual_select_group, GLX_EXT_texture_from_pixmap
    GLX version: 1.2
    GLX extensions:
        GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context, 
        GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_allocate_memory, 
        GLX_MESA_copy_sub_buffer, GLX_MESA_swap_control, 
        GLX_MESA_swap_frame_usage, GLX_OML_swap_method, GLX_SGI_make_current_read, 
        GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample, 
        GLX_SGIX_fbconfig, GLX_SGIX_visual_select_group
    OpenGL vendor string: Tungsten Graphics, Inc
    OpenGL renderer string: Mesa DRI Intel(R) 945GM 20061017 x86/MMX/SSE2
    OpenGL version string: 1.3 Mesa 6.5.2
    OpenGL extensions:
        GL_ARB_depth_texture, GL_ARB_fragment_program, GL_ARB_imaging, 
        GL_ARB_multisample, GL_ARB_multitexture, GL_ARB_point_parameters, 
        GL_ARB_shadow, GL_ARB_texture_border_clamp, GL_ARB_texture_compression, 
        GL_ARB_texture_cube_map, GL_ARB_texture_env_add, 
        GL_ARB_texture_env_combine, GL_ARB_texture_env_crossbar, 
        GL_ARB_texture_env_dot3, GL_ARB_texture_mirrored_repeat, 
        GL_ARB_texture_rectangle, GL_ARB_transpose_matrix, 
        GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_window_pos, 
        GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color, 
        GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate, 
        GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_clip_volume_hint, 
        GL_EXT_cull_vertex, GL_EXT_compiled_vertex_array, GL_EXT_convolution, 
        GL_EXT_copy_texture, GL_EXT_draw_range_elements, GL_EXT_fog_coord, 
        GL_EXT_histogram, GL_EXT_multi_draw_arrays, GL_EXT_packed_pixels, 
        GL_EXT_point_parameters, GL_EXT_polygon_offset, GL_EXT_rescale_normal, 
        GL_EXT_secondary_color, GL_EXT_separate_specular_color, 
        GL_EXT_shadow_funcs, GL_EXT_stencil_wrap, GL_EXT_subtexture, 
        GL_EXT_texture, GL_EXT_texture3D, GL_EXT_texture_edge_clamp, 
        GL_EXT_texture_env_add, GL_EXT_texture_env_combine, 
        GL_EXT_texture_env_dot3, GL_EXT_texture_filter_anisotropic, 
        GL_EXT_texture_lod_bias, GL_EXT_texture_object, GL_EXT_texture_rectangle, 
        GL_EXT_vertex_array, GL_3DFX_texture_compression_FXT1, 
        GL_APPLE_client_storage, GL_APPLE_packed_pixels, 
        GL_ATI_blend_equation_separate, GL_IBM_rasterpos_clip, 
        GL_IBM_texture_mirrored_repeat, GL_INGR_blend_func_separate, 
        GL_MESA_pack_invert, GL_MESA_ycbcr_texture, GL_MESA_window_pos, 
        GL_NV_blend_square, GL_NV_light_max_exponent, GL_NV_texture_rectangle, 
        GL_NV_texgen_reflection, GL_NV_vertex_program, GL_NV_vertex_program1_1, 
        GL_OES_read_format, GL_SGI_color_matrix, GL_SGI_color_table, 
        GL_SGIS_generate_mipmap, GL_SGIS_texture_border_clamp, 
        GL_SGIS_texture_edge_clamp, GL_SGIS_texture_lod, GL_SGIX_depth_texture, 
       visual  x  bf lv rg d st colorbuffer ax dp st accumbuffer  ms  cav
     id dep cl sp sz l  ci b ro  r  g  b  a bf th cl  r  g  b  a ns b eat
    0x23 24 tc  0 32  0 r  y  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
    0x24 24 tc  0 32  0 r  .  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
    0x25 24 tc  0 32  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
    0x26 24 tc  0 32  0 r  .  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
    0x27 24 tc  0 32  0 r  y  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
    0x28 24 tc  0 32  0 r  .  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
    0x29 24 tc  0 32  0 r  y  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
    0x2a 24 tc  0 32  0 r  .  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
    0x2b 24 dc  0 32  0 r  y  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
    0x2c 24 dc  0 32  0 r  .  .  8  8  8  8  0  0  0  0  0  0  0  0 0 None
    0x2d 24 dc  0 32  0 r  y  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
    0x2e 24 dc  0 32  0 r  .  .  8  8  8  8  0 24  8  0  0  0  0  0 0 None
    0x2f 24 dc  0 32  0 r  y  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
    0x30 24 dc  0 32  0 r  .  .  8  8  8  8  0  0  0 16 16 16 16  0 0 Slow
    0x31 24 dc  0 32  0 r  y  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
    0x32 24 dc  0 32  0 r  .  .  8  8  8  8  0 24  8 16 16 16 16  0 0 Slow
    0x5b 32 tc  0 32  0 r  .  .  8  8  8  8  0  0  0  0  0  0  0  0 0 Ncon
    That's about it... I really don't know where to look now. I'll try to debug/trace soon, I just don't have time for this right now (y'know, real life things). As soon as I have more information, I'll post it here. Anyway, if anyone has an idea, I'd like to know! Thanks again.

  6. #6
    ClanLib Developer
    Join Date
    May 2007


    Very rarely, i see the same error that you are getting (however i do not get your clanlib 0.8 error).

    I think that problem in 0.9 may be caused by the function:
    [File: Sources/GL/GLX/opengl_window_provider_glx.cpp]
    void CL_OpenGLWindowProvider_GLX::create_new_window(con st CL_DisplayWindowDescription &desc)

    At the bottom are the following lines:

    	// make window visible:
    	XMapRaised(disp, window);
    	XSync(disp, True);
    	XSetInputFocus(disp, window, RevertToNone, CurrentTime);
    	XSync(disp, True);
    The requirement was to set the input focus to the new window (Using XSetInputFocus() ). However, it does not seem to work immediately after calling XMapRaised(). For an unknown reason, there needs to be a short delay. So i added an extra XSync() between XMapRaised() and XSetInputFocus().

    I guess that XSync() only works because it takes time to call the function ... Maybe a sleep() would have been better. But i do not know of the correct solution.

  7. #7

    Default Going back to 0.8... still no success

    I tried with up to 6 additional XSync(disp, True) calls, still without success (same error). I then tried with sleep (first with 500, then with 50), and all I got was an empty (no refresh) window, that could handle any input. Since at least 0.8 is "stable", i went back to it (uninstalled 0.9, then installed 0.8-svn).

    Naturally, the problem with the corrupted image remains. Here's a screenshot of the Basid2D example, as compiled in the Examples directory:

    Just in case it may be with the version of any dependency I may use, here the result of an ldd on the compiled basic2d example:
    $ ldd basic2d
   =>  (0xffffe000)
   => /usr/local/lib/ (0xb7f2f000)
   => /usr/local/lib/ (0xb7e87000)
   => /usr/local/lib/ (0xb7d52000)
   => /usr/local/lib/ (0xb7c4b000)
   => /usr/local/lib/ (0xb7c46000)
   => /usr/lib/ (0xb7b5c000)
   => /lib/tls/i686/cmov/ (0xb7b35000)
   => /lib/ (0xb7b29000)
   => /lib/tls/i686/cmov/ (0xb79e7000)
   => /usr/lib/ (0xb79d3000)
   => /usr/lib/ (0xb79ce000)
   => /usr/lib/ (0xb79c6000)
   => /usr/lib/ (0xb7946000)
   => /usr/lib/ (0xb78e6000)
   => /usr/lib/ (0xb77f4000)
   => /usr/lib/ (0xb77de000)
   => /usr/lib/ (0xb77bb000)
   => /usr/lib/ (0xb779c000)
   => /lib/tls/i686/cmov/ (0xb7785000)
            /lib/ (0xb7f49000)
   => /usr/lib/ (0xb7776000)
   => /lib/tls/i686/cmov/ (0xb7772000)
   => /usr/lib/ (0xb7769000)
   => /usr/lib/ (0xb7766000)
   => /usr/lib/ (0xb7761000)
   => /usr/lib/ (0xb770f000)
   => /usr/lib/ (0xb7706000)
   => /usr/lib/ (0xb76ee000)
    I don't know if any of this can ring a bell to someone... I also tried on another laptop (again with Feisty), and I've got the same problem, som I suppose I'm not the only one who got it. Anyway, I'll continue to dig on this, as I don't want to go back to re-coding all that has already been done in ClanLib.

  8. #8


    i have clanLib 0.8 and ubuntu feisty fawn and i do not have these problems. All examples work fine. Are all imagas crashed, or are there any good ones left? Maybe it is a problem of an already installed image loading library.

  9. #9


    I tried to resize to image from the Basic2D example to a factor-of-two size. It was 350x110 and loading/displaying corrupted (see screenshot in a post above). After I resized it to 256x128, the image was correctly displayed.

    Now, I know OpenGL normally only accepts power-of-2 textures. However, I supposed ClanLib was taking care of all that stuff (texture remapping on the quad, or tesselation, or whatever technique it uses). Or, maybe it is taking advantage of the GL_ARB_texture_rectangle OpenGL extension, which is enabled on my adapter/driver anyway. Anyone can tell me how the non-power-of-two images are loaded/displayed?

    I really want to use ClanLib for a projet, since I heard it was a quite mature API. I just don't understand what's happening right now, but as long as I don't correct this problem, I can't do a thing... Anyway, thanks to all who can help.

  10. #10
    Master Sorcerer
    Join Date
    Sep 2006


    It is a strange problem you got with that corruption. Since ClanLib 0.8 has been out for a long time without any reports of texture corruption like this, there has to be something very special about your system which triggers it.

    Many possibilities, including:

    • Your system memory or video card memory is defect and this particular application just happens to be the one unlucky enough to trigger it.
    • You have a library/header mismatch. For example, you may have two versions of the OpenGL libraries installed, one came with your distribution, the other got installed from Nvidia/ATI's site. The working applications may be using the working OpenGL library, while ClanLib finds the broken one.
    • Some library files are corrupted on your disk.
    • The bug is in ClanLib, but either your X11 setup or graphics card is so unusual you are the first to run a ClanLib app in that setting.

    I'd recommend you start out figuring out if you got two versions of OpenGL installed or not. If you do, uninstall the one you don't use and reconfigure+recompile ClanLib.

    If that doesn't fix it, ask your package manager to verify the integrity of all packages. This would reveal if any files on your disk somehow got corrupted. Likewise you could check if there are any updates to your packages (the OpenGL driver in particular).

    If that still doesn't fix it, your only step left is to load up a debugger. Given that you don't have a program running with ClanLib yet, I can understand if you can't be bothered to do that.

  11. #11

    Default No more crash... But still corrupted images.

    Thanks Magnus for the information. I made a couple more tests and debugging, and here's what I have:

    First of all, about the random crash thing... It was my error. My global window object was not declared as global (only in an ::Init method), so it got destroyed before I tried to use it. Also, I used ClanLib 0.65 sample code to build my own tests, so some things didn't work.

    Now, about the image "corruption": Any image with a width that is not a power of 2 gets screwed when loaded/displayed. The height doesn't seem to matter. Also, the problem occurs whether the image is a tga, png, bmp or jpg. It only happens when I use OpenGL (the basic2d_sdl example works fine). When I trace, mySurface.get_pixeldata().get_width() gives me the next power-of-two, and not the actual image width (e.g. an 300x150 image gives me a width of 512). When I check the screenshot of the "corrupted" image, it all makes sense. For whatever reason, OpenGL does not seem to create the texture the exact size (probably the GL_ARB_texture_rectangle is not *really* supported by my driver or used by ClanLib, I don't know). And I suppose ClanLib does not make any check, as to see if the created texture is of the correct size or not (I suppose it may be safe to assume it is...?). So when the pixel data is copied onto the surface, it gets offset, and that gives the result I'm seeing.

    I took the time to check through my installed packages, and I deleted 915resolution (which was a BIOS-reading hack for my video adapter) and what seemed to be a duplicate of my driver. I also removed libglut3, as it has been replaced by freeglut3 (which was also already installed). Nothing gave the expected result.

    I think it's worth noting that the problem occurs on the two laptops I tried to develop with ClanLib. Both laptop are Fujitsu (different models) with on-board Intel graphic adapters (i945 on mine, i810 on the other), running on Ubuntu Feisty, with ClanLib 0.8 (svn 2007-09-13). Although the configuration/drivers are quite similar and may be the source of the problem, it seems clear the problem does not come from corrupted packages or anything like that... right?

    So, is it normal that the "pixel data" dimensions are powers-of-two's? Is there any check for this? Is the GL_ARB_texture_rectangle is used in ClanLib?

  12. #12
    Master Sorcerer
    Join Date
    Sep 2006


    It has been some time since I last looked at the CL_Surface internals, but I believe it always creates a power-of-two texture. Although most modern cards do not require this (OpenGL 2.0 requires non-power-of-two support), at the time the code was written it was very common that drivers and/or chips did not support it. So that is why it creates the texture that size.

    Regarding the corruption, when I look at the pictures, it looks like the pitch (bytes to next line) of the pixel data in the texture is incorrect. I cannot remember if CL_Surface uploads non-power-of-two data using TexSubImage, or if it moves it to a power-of-two buffer and then uses TexImage to upload it. But basically the most likely reasons is that either ClanLib messes up the pitch when moving the data, or the Intel OpenGL driver messes up the pitch when using TexSubImage.

  13. #13

    Default CL_Sprite works...

    I didn't trace in the internals of ClanLib, but my more recent tests shows that all works fine when I'm using a CL_Sprite. The original image is 288x72, divided into six 48x72 frames. I made sure there was no power-of-two anywhere. All works fine. The very same image, when loaded as a CL_Surface, shows the corruption described.

    Is there some kind of check CL_Sprite does, that a CL_Surface should do (but doesn't)?

  14. #14


    Hi !

    I do have the same problem of corrupted images.

    My configuration is the same :
    ClanLib 0.8
    Ubuntu 7.04
    GPU : Intel 855 GM
    Driver : Mesa DRI Intel(R) 852GM/855GM 20061017 x86/MMX/SSE2
    Version : 1.3 Mesa 6.5.2

    I've just made some tests, and the problem also appears to be related to NPOT textures.

    Intel GPU are very crappy, and generally so are their drivers.

    Though, maybe is there a mean, into ClanLib, to disable NPOT textures support by forcing POT textures ?

  15. #15


    I've started to study the source code (0.8SVN) and it does not make use of NPOT textures.

    They are converted to Power Of Two. So yes, it "always creates a power-of-two texture."

    Though, I don't yet have identified the mechanism used to resize them ...

  16. #16


    same problem here...
    clanlib0.8, feisty and all...

    if using a power of two wide image the problem is gone, but for any other size it's corrupted the same way yours is...

    i'd really like to know the outcome of your "investigation"

  17. #17

    Default Using CL_Sprite instead

    I didn't exaclty solved the problem, but to avoid it, I directly use CL_Sprite objects, with a single frame. By doing that, even NPOT images can be loaded and displayed correctly.

    Not a "real" solution, but it works. And if you ever want to transform your static image to an animation, there won't be a lot to change (versus having to change your setup from CL_Surface to CL_Sprite).

    Tell me how it works for all of the you's.

  18. #18


    Good news !

    This problem seems to have been fixed with Ubuntu 7.10 :-)

    It was from the video drivers ... Update Ubuntu and everything should be ok.

  19. #19


    Indeed, it does work now with Ubuntu 7.10. Joy!

Similar Threads

  1. ClanLib crashes when creating CL_DisplayWindow with target SDL.
    By Otto (Strange) Halmén in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 01-19-2008, 08:38 AM
  2. ClanLib 0.8.0 fails to compile on Ubuntu
    By lixopmstp in forum Official ClanLib SDK Forums
    Replies: 7
    Last Post: 09-04-2007, 05:50 AM
  3. Latest windows build corrupted?
    By whisperstorm in forum Novashell Game Creation System
    Replies: 1
    Last Post: 03-03-2007, 12:22 PM
  4. [img] code in signatures or images
    By aGig in forum RTsoft Tavern
    Replies: 0
    Last Post: 01-31-2007, 02:52 AM
  5. Trying to install ClanLib on Ubuntu - zlib vs zlib1g?
    By Grant in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 12-26-2006, 05:56 AM



Posting Permissions

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