Results 1 to 6 of 6

Thread: Different Render in one program?

  1. #1
    Lesser Knight
    Join Date
    Sep 2011
    Posts
    38

    Default Different Render in one program?

    Hi,

    I want to make my program changed render in run-time.
    And it really work fine!
    But some problem going on , when I pressed some key on GL1 mode, it crash!
    if I don't press anything, GL1 work fine,too.
    I developed program on GL initially. So, it crashed necessarily when I change render to GL1 ?
    ( p.s. In SWRender, it work all fine . )

    precomp.h
    Code:
    #include <ClanLib/core.h>
    #include <ClanLib/display.h>
    #include <ClanLib/gl.h>
    #include <ClanLib/gl1.h>
    #include <ClanLib/swrender.h>
    program.cpp
    Code:
    CL_SetupGL setup_gl;
    CL_SetupGL1 setup_gl1;
    CL_SetupSWRender setup_swrender;
    switch( mode = get_graphic_mode() )
    {
    	case 0: setup_swrender.set_current(); break;
    	case 1: setup_gl1.set_current(); break;
    	case 2: setup_gl.set_current(); break;
    }

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

    Default

    It sounds like a bug in ClanLib somewhere.

    It shouldn't crash. If you have a handle left open somewhere, it should throw an exception.

    Since it works switching between clanSWRender and clanGL. It is highly likely is a bug in clanGL1.

    I'll have a look later this week, it sounds like an interesting problem.

    Note: I assume the DisplayTarget example works. But the difference is that it does not use keyboard input.

    Are you using Windows or Linux?

  3. #3
    Lesser Knight
    Join Date
    Sep 2011
    Posts
    38

    Default

    Firstly, Thanks for your respone
    I'm using Window XP, MS Visual Studio 2010 .

    P.S. Sometime crash, sometime work fine until I close it (include press keyboard).

    This is the error message VS gives me.
    At 0x03b9670b , xxx.exe occurs exception situation code: 0xC0000005: Read 0x03fa6000 , invalid.
    The memory location which occurs error is different everytime.

    The assembly ( which occurs crash ) shows like below ( looks like pionter error):
    Code:
    0x03fa6000 mov         edi,dword ptr [esi]

  4. #4

    Default

    Could you provide a code sample able to produce this problem.

  5. #5
    Lesser Knight
    Join Date
    Sep 2011
    Posts
    38

    Default

    Because the code is a work, so I delete the class I wrote.
    I found out that it work fine in all mode.
    Maybe my code has bug, not clanlib.
    Maybe it occurs by sending CL_GraphicContext to many sub-object (some class can draw its data by CL_GraphicContext it owns).
    I'll check this part later.

    the code is at attackments.project.zip

    sorry for wasting your time !!

  6. #6
    Lesser Knight
    Join Date
    Sep 2011
    Posts
    38

    Default

    I think I got what happen now.
    I use a method to copy CL_Sprite, and crash:
    Code:
    class DataManager
    {
        public:
           CL_Sprite a;
           CL_Sprite b;
       
           void read( CL_GraphicContext gc )
           {
                   a = CL_Sprite( ... );
                   b = CL_Sprite( ... );
           }
    };
    
    class MonsterList
    {
    public:
          std::vector<CL_Sprite> queue;
    
          CL_Sprite get_next()
          {
                 if( queue.empty() ) return CL_Sprite();
                 
                 CL_Sprite tmp = queue[0];
                 queue.erase( queue.begin() );
                 return tmp;
          }
    };
    
    class App
    {
    public:
        DataManager data;
        MonsterList   monster_list;
        static int main()
        {
             //...
             create_window();
             // Assume this program store gc at global scope
             data.read( gc );
             
              monster_list.queue.push_back( data.a );
              monster_list.queue.push_back( data.b );
              monster_list.queue.push_back( data.a );
              monster_list.queue.push_back( data.b );
    
              CL_Sprite current_monster;
              // game loop
              while(1)
              {
                    if( monster_is_dead )
                     current_monster = monster_list.get_next();
                    current_monster.update();
              }
    
        }
    };
    I do something like that.
    the sprite's frame is same except how many times I copy sprite.( But i want them run in different,independent frame )

    If I write like below:
    Code:
    if( monster_is_dead )
                     current_monster.set_image_data( monster_list.get_next() );
    current_monster.update();
    It crash.
    Because I want pre-load sprite in memory ( store in a object ).
    After loading , I can get the copy of CL_Sprite from manager.
    But the operator= in CL_Sprite only offer pointer copy?
    So, I try
    Code:
    b = CL_Sprite( a ); //  same result. b is point to a, not copy?
    b.set_image_data( a ); // VS 2010 give me error, when I call twice.
    b.clone( a );  // as same as set_image_data( a )
    Now my solution is make two manager( because my game is support two player).
    PlayerA read ManagerA
    PlayerB read ManagerB
    But, this lose the benefit of pre-load....
    Hope having a official solution.
    Last edited by apple1000; 09-29-2011 at 04:47 PM.

Similar Threads

  1. Render to Image
    By JoseMan in forum Official ClanLib SDK Forums
    Replies: 6
    Last Post: 08-13-2011, 08:28 AM
  2. Best way to render big background?
    By rggjan in forum Official ClanLib SDK Forums
    Replies: 8
    Last Post: 08-11-2011, 02:55 PM
  3. Render to texture
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 06-23-2011, 10:29 AM
  4. Software render fail
    By Ockonal in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 12-24-2010, 10:32 PM
  5. Render Targets
    By ShadowDust in forum Novashell Game Creation System
    Replies: 0
    Last Post: 12-21-2008, 08:13 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
  •