Results 1 to 3 of 3

Thread: Issue combining tutorials.

  1. #1

    Default Issue combining tutorials.

    First let me say hello. First time posting on the forum. I am just beginning to experiment with clanlib and I have a little issue that I hope someone could help me to better understand what is going on with the frame buffers from the CanvasAdvanced tutorial. Maybe even provide a solution. See the issue below.

    I am trying to combine the CanvasAdvanced and RTSGame tutorials to add a "fog of war" effect. However, my sprites all seem to have some sort of affect applied to them. See the picture below.

    Name:  artifact.png
Views: 8
Size:  58.4 KB

    Code:
    void World::draw()
    {
    	// Draw background 
    	CL_Rect window_rect = window.get_viewport();
    	gc.set_texture(0, background);
    	CL_Draw::texture(gc, window_rect);	
    	gc.reset_texture(0);
    
    	// Draw all gameobjects
    	{
    		std::list<GameObject *>::iterator it;
    		for(it = objects.begin(); it != objects.end(); ++it)
    			(*it)->draw();
    	}
    
    	// Draw fog of war clipping areas, everything before this will be affected by the fog of war.
    	lights.update(1);
    	// Set the working framebuffer
    	gc.set_frame_buffer(fb_lightmask);
    
    	// Clear it from last frame.
    	// -- Here is where day/night can be accomplished, but interpolating the color/alpha values.
    	gc.clear(CL_Colorf(0.0f,0.0f,0.0f,1.0f));
    		
    	// Draw the Light cutouts
    	lights.draw_clips(gc);
    
    	// We're done making our changes to the texture, so reset the buffer.
    	gc.reset_frame_buffer();
    
    	// Draw the lightmask texture
    	// The color of the texture here can influence your output.  I chose to keep it simple
    	// by staying white with 100% alpha.
    	gc.set_texture(0, light_mask);
    	gc.mult_scale(CANVAS_SCALE_X,CANVAS_SCALE_Y);
    	CL_Draw::texture(gc, CL_Rect(light_mask.get_size()), CL_Colorf(.8f, .8f, .8f, .4f));
    	gc.pop_modelview();
    
    	// Reset
    	gc.reset_texture(0);
    
    	// Draw drag area
    	if(dragging)
    	{
    		float s = (sinf(CL_System::get_time() / 200.0f) + 3.0f) / 4.0f;
    
    		
    		CL_Draw::box(gc,
    			CL_Rectf(dragArea.left - 1, dragArea.top - 1, dragArea.right + 1, dragArea.bottom + 1), 
    			CL_Colorf(0.0f, 1.0f, 0.0f, (100.0f * s)/256.0f));
    		CL_Draw::box(gc,
    			CL_Rectf(dragArea.left, dragArea.top, dragArea.right, dragArea.bottom), 
    			CL_Colorf(0.0f, 1.0f, 0.0f, (200.0f * s)/256.0f));
    		CL_Draw::box(gc,
    			CL_Rectf(dragArea.left + 1, dragArea.top + 1, dragArea.right - 1, dragArea.bottom - 1), 
    			CL_Colorf(0.0f, 1.0f, 0.0f, (100.0f * s)/256.0f));
    	}
    }

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

    Default

    Try using the clanGL target, not clanGL1.

    clanGL1 does not handle framebuffers correctly when using blend modes.

  3. #3

    Default

    Quote Originally Posted by rombust View Post
    Try using the clanGL target, not clanGL1.

    clanGL1 does not handle framebuffers correctly when using blend modes.
    Awesome! Changing to USE_OPENGL_2 fixed the issue. Thanks!

Similar Threads

  1. Issue - mixed map
    By Blast07 in forum Tanked
    Replies: 5
    Last Post: 11-14-2011, 01:17 AM
  2. Tutorials.
    By Uhfgood in forum Novashell Game Creation System
    Replies: 11
    Last Post: 03-16-2007, 08:54 AM
  3. Any ETA on new tutorials?
    By whisperstorm in forum Novashell Game Creation System
    Replies: 6
    Last Post: 03-03-2007, 06:29 AM
  4. Spellcheck on the tutorials
    By Uhfgood in forum Novashell Game Creation System
    Replies: 2
    Last Post: 11-22-2006, 04:05 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
  •