Results 1 to 4 of 4

Thread: graphics, c++ newbie

  1. #1

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    graphics, c++ newbie

    I'm new to c++ and as such I don't know a lot... especially about graphics in c++.

    I have a program in VB which I'd like to convert to C++ for obvious speed reasons, it uses the .line function of a picture box and also has a setting for SetPixelV API which is incredibly faster(usually 4-5 times). I can handle to math part but I don't know how to draw the x, y grids. I think the h file is grafix, but I'm not sure. And even after I include that I don't know what to use to actually draw the points, and hopefully lines. My program makes 3d spirographs, along with lighting, as you can imagine this is slow in VB.

    The more source you could give me on doing this, that is: lines/dots, and setting their color(s), along with includes, etc. I'd be very thankful and I'll soon release my program.

    Thanks,

  2. #2
    Addicted Member ZanM's Avatar
    Join Date
    Oct 1999
    Location
    The here and now.
    Posts
    191
    #include <wingdi.h>

    Code:
    void Marker(LONG x, LONG y, HWND hwnd) 
    { 
        HDC hdc; 
     
        hdc = GetDC(hwnd); 
            MoveToEx(hdc, (int) x - 10, (int) y, (LPPOINT) NULL); 
            LineTo(hdc, (int) x + 10, (int) y); 
            MoveToEx(hdc, (int) x, (int) y - 10, (LPPOINT) NULL); 
            LineTo(hdc, (int) x, (int) y + 10); 
    
        ReleaseDC(hwnd, hdc); 
    }
    Code:
    // Line- and arc-drawing variables 
     
    static BOOL bCollectPoints; 
    static POINT ptMouseDown[32]; 
    static int index; 
    POINTS ptTmp; 
    RECT rc; 
     
        case WM_LBUTTONDOWN: 
     
     
            if (bCollectPoints && index < 32)
            { 
                // Create the region from the client area. 
     
                GetClientRect(hwnd, &rc); 
                hrgn = CreateRectRgn(rc.left, rc.top, 
                    rc.right, rc.bottom); 
     
                ptTmp = MAKEPOINTS((POINTS FAR *) lParam); 
                ptMouseDown[index].x = (LONG) ptTmp.x; 
                ptMouseDown[index].y = (LONG) ptTmp.y; 
     
                // Test for a hit in the client rectangle. 
     
                if (PtInRegion(hrgn, ptMouseDown[index].x, 
                        ptMouseDown[index].y)) 
                { 
                    // If a hit occurs, record the mouse coords. 
     
                    Marker(ptMouseDown[index].x, ptMouseDown[index].y, 
                        hwnd); 
                    index++; 
                } 
            } 
            break;
    come on Dig you should be abble to use msdn

    LineTo, ArcTo, ellipce, rectangle, and so on .... Platform SDK --> Graphics and Multimedia --> Windows GDI --> Lines and Curves also check out Filled Shapes
    Magiaus
    Visual Basic 6.0 SP5
    Visual C++ 6.0 SP5


    The only sovereign you can allow to rule you is reason.

  3. #3

    Thread Starter
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Ok, you obviously don't know just how much of a newbie I am....

    If you could... could you make it a VC++ workspace and send me it?

    my e-mail has changed since i started my account... if you'd please... send it to [email protected]

    Thanks,

    P.S. I have a hard time making a Hello World Console app... but Ii *should* be able to make the calculations...

    sin, cos they work like y = sin(x) * 3; right?

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    yeah, and don't include <wingdi.h> but rather <windows.h> or else you get a lot of very confusing errors (all errors in VC++ are confusing, but especially if you are a newbie).
    To create a basic API application, do
    File->New->Projects->Win32 Application->A "Hello, World!" aplication. This creates a working application for you, so you get an idea of how to create windows and how to draw.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width