| | |
getting graphics into c++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2003
Posts: 3
Reputation:
Solved Threads: 0
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.
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.
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.
#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.
•
•
Join Date: Oct 2003
Posts: 3
Reputation:
Solved Threads: 0
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!
also - .net uses 'iostream' - no '.h' - it refers to iostream.h as the "old" version. thanks a lot for the code though!
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++... :-|

Oh..too bad..does that mean your code is for g++... :-|
Last edited by camelNotation; Oct 7th, 2003 at 1:34 pm.
![]() |
Similar Threads
- News Story: Is this the fastest graphics card in the world? (*nix Hardware Configuration)
- Roblox seeks Game and Graphics Guru (Software Development Job Offers)
- Graphics T and L support (Monitors, Displays and Video Cards)
- News Story: Sapphire reveals the ultimate graphics card (*nix Hardware Configuration)
- News Story: Intel committed to open source graphics drivers (Linux Servers and Apache)
- graphics card (Monitors, Displays and Video Cards)
- recommendations 4 a 3D graphics prog? (Graphics and Multimedia)
Other Threads in the C++ Forum
- Previous Thread: C++ error: 'myLineNumbers' was not declared in this scope
- Next Thread: Write code for transfering files into a directory
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





