954,152 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to learn graphical part of C++?

dear respected.......


would u plz help me to learn graphics in C++.Like drawing lines,circles,ellips etc.

Wish u all the best :mrgreen:

mishu1516
Newbie Poster
2 posts since Oct 2004
Reputation Points: 11
Solved Threads: 0
 

>would u plz help me to learn graphics in C++
C++ doesn't support graphics natively. You need to choose a graphical library or API before someone can help you with it. A few good starters are Allegro, Qt, and SDL. A quick google search will give you reams of information on them.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Look in the tutorial forum at dani too ;) and google

FireNet
Posting Whiz in Training
258 posts since May 2004
Reputation Points: 108
Solved Threads: 7
 

I know Narue will smile, but here I go again. There is a thing called BCX for free out there, that will translate rather simple basic like code to C, or with the $CPP directive to C++ code. A good way to at least study Win32 API calls.

To draw a red line from point (x=25,y=15) to point x=400,y=350) use the BCX basic code:
BCX_LINE(Form1,25,15,400,350,Red)This will translate to #define Red RGB (255,0,0)
int BCX_Line (HWND,int,int,int,int,int=0,HDC=0);

int BCX_Line (HWND Wnd,int x1,int y1,int x2,int y2,int Pen,HDC DrawHDC)
{
int a,b=0;
HPEN hOPen;

HPEN hNPen=CreatePen(PS_SOLID,1,Pen);
if(!DrawHDC) DrawHDC=GetDC(Wnd),b=1;
hOPen=SelectObject(DrawHDC,hNPen);
MoveToEx(DrawHDC,x1,y1,NULL);
a = LineTo(DrawHDC,x2,y2);
DeleteObject(SelectObject(DrawHDC,hOPen));
if(b) ReleaseDC(Wnd,DrawHDC);
return a; // true or false
}
which are mostly API calls.

Hope I did this code field stuff correctly!

vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 

Okay, I fugged up the code field thing, here it is again ...

I know Narue will smile, but here I go again. There is a thing called BCX for free out there, that will translate rather simple basic like code to C, or with the $CPP directive to C++ code. A good way to at least study Win32 API calls.

To draw a red line from point (x=25,y=15) to point x=400,y=350) use the BCX basic code:

BCX_LINE(Form1,25,15,400,350,Red)


This will translate to

#define Red RGB (255,0,0)
int BCX_Line (HWND,int,int,int,int,int=0,HDC=0);

int BCX_Line (HWND Wnd,int x1,int y1,int x2,int y2,int Pen,HDC DrawHDC)
{
  int a,b=0;
  HPEN hOPen;

  HPEN hNPen=CreatePen(PS_SOLID,1,Pen);
  if(!DrawHDC) DrawHDC=GetDC(Wnd),b=1;
  hOPen=SelectObject(DrawHDC,hNPen);
  MoveToEx(DrawHDC,x1,y1,NULL);
  a = LineTo(DrawHDC,x2,y2);
  DeleteObject(SelectObject(DrawHDC,hOPen));
  if(b) ReleaseDC(Wnd,DrawHDC);
  return a;  // true or false
}


which are mostly API calls.

Hope I did this code field stuff correctly!

vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You