Drawing to HDC

This is a discussion on Drawing to HDC within the Windows Programming forums, part of the Platform Specific Boards category; I was jst staring at my wall, it's covered in diagrams and various formulas from past projects, one of them ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    31

    Drawing to HDC

    I was jst staring at my wall, it's covered in diagrams and various formulas from past projects, one of them was my opengl gui lib which I never even finished. All of a sudden I have an urge to start a similar experiment.

    I am wanting to create my own API for drawing on a "canvas" I guess you could say. Now, say all of my drawing operations have finished and it's all been processed into a bitmap. Should I just go ahead and patblt or something? Is this the best way to do it?? Is there a quicker way to draw a bitmap on the screen? Do I have to use a DC and do I have to use the Win32API to access it?

    It's nearly 3am so I'm probably making no sense, and I did search and I'm pretty sure that I do need to use a DC and can't just manipulate the memory block for my "canvas" directly.

    How, for instance, does OpenGL draw to the screen?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Use BitBlt
    Do I have to use a DC and do I have to use the Win32API to access it?
    Yes

    How, for instance, does OpenGL draw to the screen?
    OpenGL accesses the video card directly through its OpenGL driver.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    If you wish to manipulate the raw memory of a bitmap, you can use a dib section. However, as Bithub pointed out, you will still ultimately have to use BitBlt to copy it to the screen or a window. Otherwise, you might be able to use DirectX or OpenGL to copy to the screen.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    31
    I see, interesting. Thanks guys. That'll give me a start at least.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    31
    Ok, so I've created a scene graph sort of system I guess you would call it using all my own drawing functions which are as yet pretty well untested. All my operations should go onto a temporary DC and then BitBlt to the destination DC correct?

    Basically it's like draw a circle with radius from point x,y draw bitmap cx,cy at x,y etc and I just copy bits from buffers into a final bitmap like memory block... Is this making sense? If so, can anyone offer any resources (perhaps links to opensource drawing applications or something so I can perhaps get some ideas as to the best way to do all this)... I've had a bit of a search on places like sourceforge and such but I haven't found much relevant info yet.
    Last edited by Ichmael™; 03-09-2006 at 04:50 AM.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    All my operations should go onto a temporary DC and then BitBlt to the destination DC correct?
    Yes, if you want to do double buffering. If you don't want to double buffer your scene, then just draw directly to the HDC.

    As for resources, a good place to start would be the Windows GDI page.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My progress.. thnx to Cprogramming forumites
    By csonx_p in forum Windows Programming
    Replies: 6
    Last Post: 05-21-2008, 02:17 AM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 01:17 AM
  3. My first "real" windows app
    By JoshR in forum Windows Programming
    Replies: 2
    Last Post: 07-28-2005, 08:40 AM
  4. destroywindow() problem
    By algi in forum Windows Programming
    Replies: 6
    Last Post: 03-27-2005, 11:40 PM
  5. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21