|
-
Oct 26th, 2001, 01:38 PM
#1
Thread Starter
So Unbanned
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,
-
Oct 26th, 2001, 01:59 PM
#2
Addicted Member
#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.
-
Oct 26th, 2001, 09:50 PM
#3
Thread Starter
So Unbanned
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?
-
Oct 27th, 2001, 05:59 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|