getting graphics into c++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2003
Posts: 3
Reputation: rms360 is an unknown quantity at this point 
Solved Threads: 0
rms360 rms360 is offline Offline
Newbie Poster

getting graphics into c++

 
0
  #1
Oct 6th, 2003
i've done a of couple searches on this board and i haven't really found any answer to this. so-

how can i get graphics into my c++ programs. From the books i've been looking through there aren't many, if any graphic commands, in the .net and visual c++ versions of c++. (if im wrong feel free to yell at me - im running .net on windows XP) I've looked at a couple sites for 3d graphics programs (3d game studio and Darkbasic?) I played around with 3d game studio for a little while but didnt acomplish much. Is there a way to run graphics from one of these with c++. I havent really linked any files together yet in the compiler or anything along those lines. Not trying to sound stupid here , only made it through have of my text book so far - let me know if theres any simple answers , or totally not simple answers. thanks a lot.
Reply With Quote Quick reply to this message  
Join Date: Oct 2003
Posts: 766
Reputation: )BIG"B"Affleck can only hope to improve 
Solved Threads: 7
)BIG"B"Affleck's Avatar
)BIG"B"Affleck )BIG"B"Affleck is offline Offline
Banned

Re: getting graphics into c++

 
0
  #2
Oct 6th, 2003
http://www.accu.org/bookreviews/publ...b/graphics.htm
#include <iostream.h>
#include <g2++.h>
#include <g2_X11++.h>

const int HEIGHT= 200;
const int WIDTH = 200;

int main(void)
{
int window;

/* Open a window on screen. Keep it's device ID */
window = g2_open_X11(WIDTH, HEIGHT);

/* Let's define some colors now */
int black_ink = g2_ink(window,0,0,0);
int blue_ink = g2_ink(window,0,0,1);
int yellow_ink = g2_ink(window, 0.7,0.7,0);
int white_ink = g2_ink(window,1,1,1);

/* clear screen */
g2_clear(window);
g2_set_background(window, black_ink);

/* Give it a face */
g2_pen(window,yellow_ink);
g2_filled_circle(window,100,100,50);

/* and eyes */
g2_pen(window,white_ink);
g2_filled_ellipse(window,85,115,9,6);
g2_filled_ellipse(window,115,115,9,6);
g2_pen(window,blue_ink);
g2_filled_circle(window,83,115,5);
g2_filled_circle(window, 113,115,5);
g2_pen(window,black_ink);
g2_filled_circle(window,83,115,3);
g2_filled_circle(window,113,115,3);

/* and a nose */
g2_pen(window,black_ink);
g2_line(window,102,105,95,88);
g2_line(window,95,88,102,88);

/* and a mouth */
g2_line(window,90,80,110,80);

cin.get();
g2_close(window);

return 0;
}

Enter this in an Edit window and save it just as you would any other C++ program. (Remember to end the file name with .cpp to distinguish it as a C++ source code.) This example displays the picture to the right on the screen. There are a few things to note about this progam:

* The placement of the necessary lines to open up the graphics library,
* The last line, cin.get(), which makes the program wait for a return character from the keyboard.
Last edited by )BIG"B"Affleck; Oct 6th, 2003 at 8:41 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2003
Posts: 3
Reputation: rms360 is an unknown quantity at this point 
Solved Threads: 0
rms360 rms360 is offline Offline
Newbie Poster

Re: getting graphics into c++

 
0
  #3
Oct 6th, 2003
thanks a lot , that'll help a lot - are there ways to import other graphic files into the program though? bitmaps, gifs , whatever 3d files are? (dont really have any idea how i'd use them than , but just wondering)

also - .net uses 'iostream' - no '.h' - it refers to iostream.h as the "old" version. thanks a lot for the code though!
Reply With Quote Quick reply to this message  
Join Date: Oct 2003
Posts: 3
Reputation: rms360 is an unknown quantity at this point 
Solved Threads: 0
rms360 rms360 is offline Offline
Newbie Poster

Re: getting graphics into c++

 
0
  #4
Oct 6th, 2003
ok - i tried the code , .net tells me it doesnt have the iostream.h or either of the other 2. im not sure if im just missing something or what?
Reply With Quote Quick reply to this message  
Join Date: Sep 2003
Posts: 208
Reputation: camelNotation is an unknown quantity at this point 
Solved Threads: 2
camelNotation's Avatar
camelNotation camelNotation is offline Offline
Posting Whiz in Training

Re: getting graphics into c++

 
0
  #5
Oct 7th, 2003
Will your code execute allright in vc++6,B?
Reply With Quote Quick reply to this message  
Join Date: Oct 2003
Posts: 766
Reputation: )BIG"B"Affleck can only hope to improve 
Solved Threads: 7
)BIG"B"Affleck's Avatar
)BIG"B"Affleck )BIG"B"Affleck is offline Offline
Banned

Re: getting graphics into c++

 
0
  #6
Oct 7th, 2003
end the file name with .cpp

oh im sorry we need a g++ forum
Last edited by )BIG"B"Affleck; Oct 7th, 2003 at 10:55 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2003
Posts: 208
Reputation: camelNotation is an unknown quantity at this point 
Solved Threads: 2
camelNotation's Avatar
camelNotation camelNotation is offline Offline
Posting Whiz in Training

Re: getting graphics into c++

 
0
  #7
Oct 7th, 2003
That means you're using Linux ? Ok..then.I don't know the diff between vc++6 and vc++.net . I bought the 2000 enterprise edition recently I don't wanna buy that 7 cd .net edition right now
Oh..too bad..does that mean your code is for g++... :-|
Last edited by camelNotation; Oct 7th, 2003 at 1:34 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2003
Posts: 117
Reputation: subtronic is an unknown quantity at this point 
Solved Threads: 1
subtronic's Avatar
subtronic subtronic is offline Offline
Junior Poster

Re: getting graphics into c++

 
0
  #8
Oct 7th, 2003
Richard Stallman is coming to speak at the University of New Mexico on Wednesday
Reply With Quote Quick reply to this message  
Join Date: Sep 2003
Posts: 208
Reputation: camelNotation is an unknown quantity at this point 
Solved Threads: 2
camelNotation's Avatar
camelNotation camelNotation is offline Offline
Posting Whiz in Training

Re: getting graphics into c++

 
0
  #9
Oct 7th, 2003
I'm ashamed I don't know who is Richard Stallman? Btw, who is Stroustrup-the inventor of c++? is it a super comp or just a person.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: adaquyenpn is an unknown quantity at this point 
Solved Threads: 0
adaquyenpn adaquyenpn is offline Offline
Newbie Poster
 
-3
  #10
29 Days Ago
It's too complect
Last edited by adaquyenpn; 29 Days Ago at 5:33 am.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC