943,584 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 48256
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 6th, 2003
-1

getting graphics into c++

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rms360 is offline Offline
3 posts
since Oct 2003
Oct 6th, 2003
0

Re: getting graphics into c++

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.
Reputation Points: 25
Solved Threads: 8
Banned
)BIG"B"Affleck is offline Offline
766 posts
since Oct 2003
Oct 6th, 2003
0

Re: getting graphics into c++

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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rms360 is offline Offline
3 posts
since Oct 2003
Oct 6th, 2003
0

Re: getting graphics into c++

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rms360 is offline Offline
3 posts
since Oct 2003
Oct 7th, 2003
0

Re: getting graphics into c++

Will your code execute allright in vc++6,B?
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
camelNotation is offline Offline
208 posts
since Sep 2003
Oct 7th, 2003
0

Re: getting graphics into c++

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.
Reputation Points: 25
Solved Threads: 8
Banned
)BIG"B"Affleck is offline Offline
766 posts
since Oct 2003
Oct 7th, 2003
0

Re: getting graphics into c++

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.
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
camelNotation is offline Offline
208 posts
since Sep 2003
Oct 7th, 2003
0

Re: getting graphics into c++

Richard Stallman is coming to speak at the University of New Mexico on Wednesday
Reputation Points: 44
Solved Threads: 1
Junior Poster
subtronic is offline Offline
117 posts
since Aug 2003
Oct 7th, 2003
0

Re: getting graphics into c++

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.
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
camelNotation is offline Offline
208 posts
since Sep 2003
Oct 27th, 2009
-3
Re: getting graphics into c++
It's too complect
Last edited by adaquyenpn; Oct 27th, 2009 at 5:33 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
adaquyenpn is offline Offline
1 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C++ Forum Timeline: Boost.Regex
Next Thread in C++ Forum Timeline: Help with insertion sort





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC