Results 1 to 1 of 1

Thread: Shadows and lights

  1. #1
    Serf
    Join Date
    Apr 2009
    Location
    Finland
    Posts
    4

    Default Shadows and lights

    Hello!
    I am trying to do lights and shadows in ClanLib 0.9. Actually I have already done shadows (look the attachment), but lights are problem. This is what I am trying to do.
    I have tried to do it using CL_PixelBuffer, but it is probably too slow and doesn't even seem to work. Have I understood something wrong or is it maybe a bug? This code creates graphical mess, but e.g. 200x200 image works:
    Code:
    int width = 400, height = 300;
    CL_PixelBuffer buffer(width, height, width*4, CL_PixelFormat::rgba8888);
    unsigned int *pixel_data = (unsigned int *) buffer.get_data();
    for (int y = 0; y < height; y++)
    {
    	for (int x = 0; x < width; x++)
    	{
    		unsigned char red = 255-((float)x/width*255);
    		unsigned char green = 255-((float)y/height*255);
    		unsigned char blue = x;
    		unsigned char alpha = 255;
    		pixel_data[x + y * height] =
    			(red << 24) + (green << 16) + (blue << 8) + alpha;
    	}
    }
    gc.draw_pixels(0, 0, buffer);
    Then I thought that maybe it's faster to do it using OpenGL, but I have no idea how to do that. Or is it even possible? How I use OpenGL with ClanLib and how I do lights in 2D?

    Also, is there an easy way to draw polygons in ClanLib? Now I divide polygons to triangles and draw them, but I can't get it work right.
    Attached Images Attached Images  

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
  •