Results 1 to 3 of 3

Thread: Blank Surface

  1. #1

    Default Blank Surface

    I'm after creating a blank (transparent) surface to draw on. Such as:

    //Draws surface 2 onto surface 1
    CL_Canvas Canvas;
    Canvas.select_surface(m_Surface1);
    Surface2.draw(30,30, Canvas.get_gc());

    In this example, surface 2 would have an image loaded, but surface 1 would be transparent (have no image loaded).

    Right now, creating CL_Surface as: Surface1 = new CL_Surface() will generate an exception.

    Thanks.

  2. #2

    Default

    It seems a blank surface can be created as follows (If I'm wrong, please tell me)...

    Code:
    Pixels = new CL_PixelBuffer(512, 512, 1024, CL_PixelFormat::rgba8888, NULL);
    m_Surface = new CL_Surface(*Pixels);
    Given that in the real apps, a pixel buffer could be any size and may have any number of differently sized images draw onto it, does anybody know to what value I should set pitch?

    Thanks.
    Last edited by ART_Adventures; 09-22-2006 at 11:31 AM.

  3. #3
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    Quote Originally Posted by ART_Adventures View Post
    It seems a blank surface can be created as follows (If I'm wrong, please tell me)...

    Code:
    Pixels = new CL_PixelBuffer(512, 512, 1024, CL_PixelFormat::rgba8888);
    m_Surface = new CL_Surface(*Pixels);
    Given that in the real apps, a pixel buffer could be any size and may have any number of differently sized images draw onto it, does anybody know to what value I should set pitch?
    That's right, except In your example code, you're setting the pitch incorrectly. You probably want to set this to 512*4; the exact space a row of pixels will take on the X axis. (CL_PixelFormat::rgba8888()->get_depth()/8) will show the size to be 4 bytes, ie, 32 bits per pixel)

    Example:

    Code:
    int sizeX = 512;
    int sizeY = 512;
    Pixels = new CL_PixelBuffer(sizeX, sizeY, sizeX*4, CL_PixelFormat::rgba8888, NULL);
    Now, this is just sitting in system memory for you to tweak or do whatever to. (you have access to the pure data if you want)

    When you do "m_Surface = new CL_Surface(*Pixels);" it creates a surface on the video card for optimized drawing speed (it copies the pixel buffer over to the card), the original pixel buffer isn't used again in this case.
    Seth A. Robinson
    Robinson Technologies

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
  •