Results 1 to 4 of 4

Thread: simple ClanLib example problem - segfault

  1. #1

    Default simple ClanLib example problem - segfault

    hi to all. I'm trying to run simple ClanLib example, but it returns Segmentation fault on Kubuntu GNU/Linux 7.04. ClanLib-0.8 was configured with -prefix=/usr/lib and compiled. I set all environment variables and CPP flags to header's and lib's directories, so simple app like this

    Code:
    #include <ClanLib/application.h>
    #include <ClanLib/core.h>
    #include <ClanLib/display.h>
    #include <ClanLib/gl.h>
    #include <ClanLib/sound.h>
    
    class phx_clanApplication : public CL_ClanApplication
    {
    public:
    	virtual int main(int argc, char** argv)
    	{
    		
    		CL_SetupCore::init();
    		CL_SetupDisplay::init();
    		CL_SetupGL::init();
    		CL_SetupSound::init();
    		
    		// Code here
    		CL_DisplayWindow window("first Clanlib window", 640, 480);
    		
    		CL_SetupSound::deinit();
    		CL_SetupGL::deinit();
    		CL_SetupDisplay::deinit();
    		CL_SetupCore::deinit();
    		return 0;
    	}
    } app;
    compiles and runs well, without any error.
    but if I add some simple draw fuctions like these


    Code:
    //the same includes as above
    
    class phx_clanApplication : public CL_ClanApplication
    {
    public:
    	virtual int main(int argc, char** argv)
    	{
    		CL_SetupCore::init();
    		CL_SetupDisplay::init();
    		CL_SetupGL::init();
    		CL_SetupSound::init();
    		
    		// Code here
    		CL_DisplayWindow window("first Clanlib window", 640, 480);
    		CL_GraphicContext *gc = window.get_gc();
    		gc->clear(CL_Color::black);
    		gc->draw_line(100, 100, 400, 400, CL_Color::red);
    		gc->draw_rect(CL_Rect(101,101,399,399), CL_Color::blue);
    		
    		CL_SetupSound::deinit();
    		CL_SetupGL::deinit();
    		CL_SetupDisplay::deinit();
    		CL_SetupCore::deinit();
    		return 0;
    	}
    } app;
    it returns Segmentation fault (core dumped) on string
    Code:
    return 0;
    if I replace this string with another one
    Code:
    exit (0);
    this runs fine. but in both examples there aren't any line or rectangle on screen - it even does not clears screen on
    Code:
     gc->clear(CL_Color::black);
    so, the question is: what's wrong with those examples? thank you.

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

    Default

    If you try the example at the end of the file called INSTALL.linux
    (see section 5. Creating a simple application) - does that crash as well? If so, try using the alternative setup_ method in the beginning (instead of callng the static functions like you do now)

  3. #3

    Default

    oh, thank you! example from INSTALL.linux works fine! hmmmm, but new problem occured - some surfaces aren't displayed properly. for example, this image (in .png format)

    is displayed as


    my code is simple:

    Code:
    #include <ClanLib/gl.h>
    #include <ClanLib/core.h>
    #include <ClanLib/application.h>
    #include <ClanLib/display.h>
    
    class MyApp : public CL_ClanApplication
    {
    	public:
    		virtual int main(int argc, char **argv)
    		{
    			try
    			{
    				CL_SetupCore setup_core;
    				CL_SetupDisplay setup_display;
    				CL_SetupGL setup_gl;
    
    				CL_DisplayWindow window("ClanLib application", 640, 480);
    				
    //here we create pointer to CL_Surface object
    				CL_Surface *s1;
     				s1 = new CL_Surface (PATH_TO_IMAGE);
    
    				while (!CL_Keyboard::get_keycode(CL_KEY_ESCAPE))
    				{
    					CL_Display::clear(CL_Color(0, 0, 50));
    
    //here we drow the surface
    					s1 -> draw (10, 10);
    
    
    				
    					CL_Display::flip();
    
    
    					CL_System::keep_alive(10);
    				}
    			}
    
    			catch (CL_Error err)
    			{
    
    				std::cout << err.message.c_str() << std::endl;
    			}
    
    			console.display_close_message();
    
    			return 0;
    		}
    } app;
    so, what can be wrong? image is created with Gimp, and all checkboxes in format settings are off. it seems to me, that problem is in image format - because some of jpeg and png files are displayed properly, but some not. and I cant define, what option makes images not readable for ClanLib CL_Surface.
    Last edited by phx_one; 02-17-2008 at 02:37 PM. Reason: dead image link

  4. #4
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Update your display driver - it doesn't properly deal with pitch/stride when uploading textures.

Similar Threads

  1. Simple app won't compile when linked with clanlib
    By mmiikkee12 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-17-2007, 02:41 PM
  2. Problem building ClanLib
    By jtaylor1126 in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 03-31-2007, 12:10 AM
  3. More on the green line problem, bug in Clanlib?
    By pTymN in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 03-22-2007, 04:43 PM
  4. ClanLib-0.8.0\Tests\NetSessionsTest problem
    By inxbus in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 01-06-2007, 09:11 PM

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
  •