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.

Recommended Answers

All 11 Replies

#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_set_background(window, black_ink);

/* Give it a face */

/* and eyes */
g2_filled_circle(window, 113,115,5);

/* and a nose */

/* and a mouth */


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.

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!

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?

Will your code execute allright in vc++6,B?

end the file name with .cpp

oh im sorry we need a g++ forum

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 :confused:
Oh..too bad..does that mean your code is for g++... :-|

Richard Stallman is coming to speak at the University of New Mexico on Wednesday :)

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.

It's too complect

commented: You bumped a 7 year old thread. +0

It's too complect

K, so this topic was, like, 6 years old, right? And you effed it up with spam.

can sombody make a simple project of graphics in c++?
i will be happy and mercifull please help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.