# C++ Graphics Programming



## m-jeri (Sep 19, 2005)

Hi Guys,

Here i saw the threads on c/c++ pgmming.
This one is for doing *programming in c++
with graphics library*
ie creating menus,windows,API's...

Share your knowledge here.

Greetings

Bye


----------



## ashu888ashu888 (Sep 19, 2005)

Yaa guys even i wanna learn sum graphics with the help of graphics library..It would be helpful if users here can giv links or post simple codes or even explain them by giving a simple logic to the same.. 

Also plz (if any of the users know) plz include the details of wat things can be done using graphics in C++ Programming... as it will be a gr8 boost to share new things in C++ Graphics related Programming..

*It would help users like me if u start with the basics of Graphics in C++ * as i already know the normal C++ programming.. 
Cheers n e-peace....


----------



## NikhilVerma (Sep 19, 2005)

Well what to share over here ? Experiences ?

Well I have always loves programming Graphics in C++...
Made a Bump Mapping on it...

Also a GUI for C++ using graphics.h
Containing fully functional classes such as 

TextBox
CheckBox
Window
Radio Button
Standard Button

With every thing customisable....

Stopped work later... Coz I couldn't figure out how to do the context menu...

Would love to see more guys of my type ...


----------



## m-jeri (Sep 20, 2005)

yeah right

see the response for a post for eduction noone cares
This is one g8 forum
BTW guys who replied thx

and me 2 have done fully functional and alterable classes
for
1.button
2.message box with click buttons(1 or 2)
3.Windows
4.Tree Views
5.Drop down menus
6.Switch based interface

ashu888ashu888 ask for help,if i know i will give

NikhilVerma,dude could u post it here or
send to mail madjeri2003@hotmail.com.
If its better than mine it will be helpful
bye guys posted keep posting and help each other out


----------



## bizzare_blue (Sep 21, 2005)

I too am workin on graphics in c++ and m interested in it too...m currently workin on a project n will b askin 4 help from u guys if i need it...thnx in advance 4 the same...


----------



## m-jeri (Sep 21, 2005)

feel free to ask.thats what it is all about.

Hey Nikhil u there


----------



## NikhilVerma (Sep 21, 2005)

madjeri man !
You reminded me of my old days... 
I worked in C++ graphics all the time ! 
Now I feel like continuing what I left...

BTW I don't want to post those classes over here coz of pilagrism troubles...
So mailing you instead...

Would like to see your work too...


----------



## ashu888ashu888 (Sep 22, 2005)

*madjeri  wrote:*


> yeah right
> 
> see the response for a post for eduction noone cares
> This is one g8 forum
> ...



Hey buddy can u tell me wat and from where can i start this C++ Graphics Programming?>?? ( i already know C++ Programming but not the Graphics part so im a newbie to this..so if u and other guys can help me out as to how to start from SCRATCH abt Graphics then plz post it... as it will be really helpful...

I am having the *TURBO C compiler*

Cheers n e-peace.....


----------



## bizzare_blue (Sep 22, 2005)

If u r havin TURBO C then it would be better to learn from the examples....Open BGIDEMO.C file n run it....Now copy n paste various codes(drawing lines,circles,arcs etc) from that file into ur own program n change it as u want....use the 'HELP' too....I learnt it this way n this really works man!!!! So try it out.


----------



## ashu888ashu888 (Sep 22, 2005)

*bizzare_blue wrote:*


> If u r havin TURBO C then it would be better to learn from the examples....Open BGIDEMO.C file n run it....Now copy n paste various codes(drawing lines,circles,arcs etc) from that file into ur own program n change it as u want....use the 'HELP' too....I learnt it this way n this really works man!!!! So try it out.


Hey blue,buddy i tried opening the BGIDEMO.C file in my Turbo C Compiler and wen i tried to see the output screen (pressing ALT+F5),it gave me this messege: * Graphics System Error: Device driver file not found (EGAVGA.BGI) *    Now wat shud i do??? 

While Compiling this code (by pressign Alt+F9) i dont get any error also while Running the code( by pressing Ctrl+F9) there is no problem at all.. I get this msg only wen i see the output screen... 

Shud i post the code also ??   (the code is really too big in notpad format) but if u or any of the users want it then i will post it...Help plz..

Cheers n e-peace......


----------



## NikhilVerma (Sep 22, 2005)

This problem can be solved easily...
First of all chck that a file called "egavga.bgi" exists or not... if not then take it from the link below...
Then place it in the directory of your program...
And change the initgraph function to this...



> initgraph(&gd,&gm,"");



it will surely work then....
BTW I have made another program today... It's called the polygon tweener....



> To use it :
> *1) Extract all the files in a directory
> 2) Run the program and draw a polygon by clicking... Don't click more than 500 times
> 3) Right click
> ...



Here is the link....

*rapidshare.de/files/5404983/POLYGON.zip.html

Tellme what do you guys think about it.....


----------



## __Virus__ (Sep 22, 2005)

been into programming and i know it demands to code off our a...s...great proggy man


----------



## ashu888ashu888 (Sep 23, 2005)

*NikhilVerma wrote:*


> This problem can be solved easily...
> First of all chck that a file called "egavga.bgi" exists or not... if not then take it from the link below...
> Then place it in the directory of your program...
> And change the initgraph function to this...
> ...


Well i hv the EGAVGA.BGI file in my directory but i cannot find the command where its written *initgraph(&gd,&gm,""); *

I am pasting the code so plz lotace me the command where its written and then i will change it as im not able to find it guys  If u find it..plz HIGHLIGHT tat line or copy and type it in BOLD so tat i can then change it in my original code.....Thanx a lot..as ur help will be really helpful....

*The code is as follows"*



> /*
> GRAPHICS DEMO FOR Borland C++ 3.0
> 
> Copyright (c) 1987,88,91 Borland International. All rights reserved.
> ...


_

Please help me guys !!!! 

Cheers n e-peace......._


----------



## NikhilVerma (Sep 23, 2005)

DUDE !!!! Remove that piece of code!!!

My firefox is showing glitches !!!

just open the file in Notepad and search for "initgraph" and you will find it....
Although I have seen the code and found the the line and it's okay... But I still don't know why is the problem occuring...

You should reinstall turboc...


----------



## ashu888ashu888 (Sep 23, 2005)

*NikhilVerma wrote:*


> Although I have seen the code and found the the line and it's okay... But I still don't know why is the problem occuring...
> 
> You should reinstall turboc...


Been there Done that...i reinstalled TURBO C..no effect still  Did u find the line in my CODE ?? where?? i was unable to find it  can u telll me in wich function name does tat command line exists?? 

Shud i view my prog in 256 color mode or sumthing like tat..    

If u hv ur own *BGIDEMO.C* file then can u mail it to me...(i hope ur code and my code does not hv compatibility problems wen i run it on my Compiler..   
My email is *ashu888ashu888@yahoo.com*

Cheers n e-peace....


----------



## m-jeri (Sep 23, 2005)

ashu try to get a new turbo c++ compiler.
If you dont find initgraph dont worry.
just add this
int gd=DETECT,gm;          //graphic initialisation
initgraph(&gd,&gm,"c:\\tc\\bgi");

c:\\tc\\bgi is your tc location and make sure tc is in c drive.

BTW initgraph is just intialising your graphics driver.

bye


----------



## NikhilVerma (Sep 23, 2005)

I don't need to mail that file to you....

Just download it from the link I gave in my third last post...


----------



## ashu888ashu888 (Sep 24, 2005)

*madjeri wrote:*


> ashu try to get a new turbo c++ compiler.
> If you dont find initgraph dont worry.
> just add this
> int gd=DETECT,gm; //graphic initialisation
> ...


Well where shud i add this code bro !  in the main() function ?? is it??    well yes my TURBO C compiler is in the C:


----------



## NikhilVerma (Sep 24, 2005)

ofcource you have to add this in your main function !!! Isn't that obvious ???

You should try to do something before starting to post about minor problems...


----------



## m-jeri (Sep 24, 2005)

yo nikhil links aint working and u send it to my mail ok


----------



## NikhilVerma (Sep 24, 2005)

The link is working here....

You need to click on the "Free" button below and then wait for the file's link to show up at the bottom....


----------



## ashu888ashu888 (Sep 24, 2005)

*madjeri wrote:*


> ashu try to get a new turbo c++ compiler.
> If you dont find initgraph dont worry.
> just add this
> int gd=DETECT,gm; //graphic initialisation
> ...


I did tat in the mai() but i got *1 error--->  int gd=DETECT,gm;               Declaration not allowed here*      and        * 1 Warning---->  initgraph(&gd,&gm,"c:\\tc\\bgi");          'gd' is assigned a value that is never used.*

I replaced this tag *c:\\tc\\bgi* with *c:\\turboc3\\tc\bgi* as my TURBOC3 folder (on the C: drive) wich contains the TC folder in wich the BGI and other folders are present.

but still no luck guys !  the program fails to run coz of the ERROR tat i get..   i specified both the codes in the *int main()* function and outside the *if loop* but still same problem 
Please suggest sumthing....

cheers n e-peace....


----------



## NikhilVerma (Sep 24, 2005)

Forget that length program for the moment...
use this program and 

*PLACE THE EGAVGA.BGI FILE IN THE PROGRAM'S DIRECTORy*

and then compile it.... don't change anything in it...
Tellme what happens...


```
#include<graphics.h>
#include<conio.h>
void setmode()
{
	int gd=DETECT,gm;
	initgraph(&gd,&gm,"");
}
void main()
{
	setmode();
	int i,j;
	for(i=0;i<640;i+=5)
	{
		line(i,0,i,480);
		line(0,i,640,i);
	}
	for(i=0;i<640;i+=5)
	{
		for(j=0;j<480;j+=5)
		{
			setfillstyle(1,(i*j+i*i+j*j));
			floodfill(i-1,j-1,15);
		}
	}
	getch();

}
```


----------



## ashu888ashu888 (Sep 26, 2005)

Yup Nikhil, i hv the EGAVGA.BGI (BGI file) in my BGI folder and i ran ur code also but it gives me this msg:


> #include<graphics.h>
> #include<conio.h>
> void setmode()
> {  int gd=DETECT,gm;
> ...



Dont knw wat else shud i do...   Help !!


----------



## NikhilVerma (Sep 26, 2005)

Okay then I guess there is a problem with your C installation...

I think you should get another version of TurboC ... The one I have is 3.0...
And it doesn't have any sub-directories... Install file is named turboc.exe

see if you can find it on any of your friends PC or ask your teacher maybe...


----------



## ashu888ashu888 (Sep 27, 2005)

*NikhilVerma wrote:*


> I think you should get another version of TurboC ... The one I have is 3.0...
> And it doesn't have any sub-directories... Install file is named turboc.exe


Well im having TURBOC 3 buddy.....and i think its the latest.. neways will ask for a new version....

Cheers n e--peace....


----------



## puja399 (Oct 6, 2005)

R u guys from prehistoric era?!!!!! Still fumbling with turbo c++ and bgi library!!!! Wake up, learn some windows programming for heaven's sake, do some DirectX or OpenGL. This is 2005 going on to 2006, people are using Geforce 6800GT !!!!


----------



## ashu888ashu888 (Oct 7, 2005)

*puja399 wrote:*


> R u guys from prehistoric era?!!!!! Still fumbling with turbo c++ and bgi library!!!! Wake up, learn some windows programming for heaven's sake, do some DirectX or OpenGL. This is 2005 going on to 2006, people are using Geforce 6800GT !!!!


Buddy,its only tat this thread was related to C++ GRAPHICS PROGRAMMING..coz sum of our Digit users (including me ofcourse) wanted to learn the GRAPHICS features of C++.

And more importantly...To start any PROGRAMMING/GRAPHIC INTENSIVE work..u need to hv a bit of *"so-called"* COMMON sense to learn the ABC's (basics) first.. isint it !!    

If ur well versed in WINDOWS PROGRAMMING..then please do the honours and post a new thread related to same.. as tat would be helpful....

As of now..no digit user is posting their querries on this topic..so its done and dead ....

There are still users and newbies who want to learn programming rite from the basics....*No matter in watever era we people will be but we still teach a newbie the same A for apple and B for ball to make him/her understand the basics first.. isint it ??*

I guess tat even u didnt started to speak the word "PROGRAMMING", until u learned ABC rite !! 

Cheers n e-peace.....


----------



## NikhilVerma (Oct 7, 2005)

puja399 said:
			
		

> R u guys from prehistoric era?!!!!! Still fumbling with turbo c++ and bgi library!!!! Wake up, learn some windows programming for heaven's sake, do some DirectX or OpenGL. This is 2005 going on to 2006, people are using Geforce 6800GT !!!!



If you can shed any light on OpenGL and DirectX programming rather than mocking us... We'd be glad...


----------



## bizzare_blue (Oct 7, 2005)

I myself was interested in DirectX prog and started a thread too but got no replies so I purchased a book by Keith Sink...Nice one 4 advanced user....Everythin is taught in it....

A good beginner's book is by Yashwant Kanitkar....its the best in its category....

But then I changed my plans n jumped 2 C++ graphics prog to start with, as they say, "BASICS"....


----------



## puja399 (Oct 7, 2005)

First of all, my sincere apology to you all if I hurt your feelings. It was not my intention to mock you that you are still using tc++ in graphics progs. But the fact remains that tc++ operates in DOS and I seriously doubt that any of the persons visiting this thread uses any OS lower than Win95. So if someone uses tc, it means he/she is downgrading to 16 bit in a dosbox which is rather peculier to me. 

 Further, tc++, as far as I know is not compliant to true c++ standards, meaning that, tc++ has no namespace, template or STL which are the heart and brain of modern C++. So, in fact, people using TC++ are actually using a language which is not 100% C++, and not even close to it. So why spent so much energy on TC++?

And do you guys really feel that putting your precious time, brain and money ( time is money you know!!) , not to talk of physical labour and lost sleep on programming with BGI library is giving you any benefit? Where would you use it ?  I don't think it has got any more utility than making some toy apps for showing off to your parents or friends. And what ashu888ashu888 has pointed out that it gives you the ABC or the basics of progs. But I think what u need is learning algorithms and not BGI programming, it will help u most. Its no use reinventing the wheel. MFC is there for you. 

And regarding learning OpenGL or DX, or even Windows progs, I confess that I possess much less knowledge than u might think I do, so that I can give others tutorials. There are more than enough wonderful free tutorials all over the net just waiting for you to read them. Moreover, windows programming especially graphics progs have  now become like rocket science, it is  deeper that the atlantic and wider than the pacific, and not a thread or a section but even a whole website like this one is much inadequate to cover even the basics of windows graphics programming.

So, first of all, I suggest that u should start using Microsoft C++ (VC++), and dump TC++ for good. Buy the famous Windows programming book by Charles Petzold and start right away. It will give all the basics u need to know for your future. I can assure u that u will forget tc++ and bgi library in no time.


----------

