A Conversation for The H2G2 Programmers' Corner

Graphics Help

Post 1

Annette

I'm working on learning C, and I'd like to be able to do graphics type things with it. Problem is, "graphics.h" isn't part of the standard function library. (At least, I don't think it is...) I've been using the Microsoft Visual C++ compiler, and I haven't been able to figure out a way to do graphics with it. So if you know of 1)a way to do graphics with visual C++ or 2)something (preferably free, or at least cheap) that I can download that will enable me to program graphics, I'd really, really appreciate it! Please excuse any ridiculous factual errors, etc, that I probably made in this post, as I am very much a beginner....


Graphics Help

Post 2

Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista)

Could you be a little more specific about what you mean by "Graphics"...?

Plotting points? Graphs and charts? Game sprites? Photo-editing? Fractals?

I'm not a C++ user myself, but I know that there are a lot of different language extensions available, each with their own strong and weak points - an idea of what you're trying to achieve might make it easier to suggest something. smiley - geeksmiley - smiley


Graphics Help

Post 3

Dogster

What you need (IMO) is Allegro which is free and can be downloaded from http://www.talula.demon.co.uk/allegro along with many helpfiles, documentation and a large support community (i.e. there are lots of tutorials for it about). The alternative is to do things the "proper" way and download a copy of the OpenGL or DirectX SDK. OpenGL is easier to use, but DirectX will probably run faster. I'm sure that both of the SDKs are absolutely gigantic to download. I recently downloaded the DirectX one which was a few hundred megabytes (but can be ordered on a CD, I think the only price is postage).


Graphics Help

Post 4

DoctorMO (Keeper of the Computer, Guru, Community Artist)

If it's just basic graphics manipulation or even skinning then I recoment the standard BitBlt graphics functions. I've used these in both VB, C++ and Assembler so no wories standard to windows, you'll have to use some hDC variable structures but the defs are included in the header file.

have a look round anyway, I'd avoid using DirectX or OpenGL unless your doing either 3D work or your looking at object theory, (like I did a few months ago).

this asumes you know how to load forms and things first.

-- DoctorMO --


Graphics Help

Post 5

MaW

The key thing is that C++ doesn't have a standard graphics toolkit as part of the language, so you're going to have to poke around, see what you have and what's available, and pick one that's suitable for your needs.

I wouldn't recommend using Windows API functions though, in my experience they're generally FREAKING HORRIBLE!!!

Ahem.


Graphics Help

Post 6

Ion the Naysayer

Dogster mentioned DirectX vs. OpenGL. If you're going to use one of those, it would be a good idea to read http://www.vcnet.com/bms/features/3d.html before you make a decision. If you have an nVidia graphics card, DirectX will probably render faster than GL but in my experience most other cards will render OpenGL faster.

I've also heard that programming for the DirectX API is like beating yourself repeatedly with a frying pan as compared to using OpenGL (that's why John Carmack of id software fame uses GL and not DirectX; feel free to look that up, btw...)


Graphics Help

Post 7

DoctorMO (Keeper of the Computer, Guru, Community Artist)

I'm a linux user and I'd recoment the windows api, it is widly available on all windows machines, it's never let me down when I do things in windows and opengl and directx are a frigin pain to init, and directx 7 used some of the api anyway for it's 2D layers.it depends if he just wants somthing that will display pritty pictures or if he's looking to make his gameing dreams come true. but I belive the question was more aimed at 'start' to program graphics.

-- DoctorMO --


Graphics Help

Post 8

MaW

How did you manage to like the Windows API, when it's one of the most mismatched and cludgy things I have ever encountered?


Graphics Help

Post 9

Annette

Thanks guys!
I've started fooling around with Windows API. It seems...well, workable, if not exactly my idea of fun. Allegro looks really neat, I'll probably download it in a day or so. OpenGL and DirectX look a little difficult for now, but maybe in a couple months....


Graphics Help

Post 10

DoctorMO (Keeper of the Computer, Guru, Community Artist)

smiley - tongueout it's to do with knowing the steps, you can't just feed someone solids you have to ween them onto it, even if the windows API is the baby food of Graphical programming.

-- DoctorMO --


Graphics Help

Post 11

MaW

Only on Windows. On Linux it's XLib, which is fairly awful by itself. Or SVGALib perhaps. Or one of the framebuffer libraries. Or libgnomecanvas! Woohoo! Or EVAS, an OpenGL-accelerated 2D drawing surface with a sane API.

Excuse me while I drool.


Graphics Help

Post 12

DoctorMO (Keeper of the Computer, Guru, Community Artist)

Are you drooling because your name space has run out for how many libaries there are? or because you just happen to like one/all/some of them?

I'd like to get into linux programming and have only managed a couple of perl scripts, a bash script and modyfing someone's game smiley - winkeye for personal use.

-- DoctorMO --


Graphics Help

Post 13

MaW

I'm drooling about EVAS actually. I must find an excuse to use that in something.


Graphics Help

Post 14

Dogster

While we're on the subject, are there any (easy to use) graphics libraries that work on unix platforms generally? (Although I suppose linux only would be fine.) More importantly, ones that I can install and use without being root? The reason is, I want to run some programs at an academic department with unix and linux computers only, and I only have an ordinary login. My needs are relatively simple: I'd like to be able to output simple 2d colour graphics (i.e. points, lines, circles, text) that update in realtime. At the moment, I'm using a library (Cgraph) which creates postscript output, which is fine for what it is but is no use for realtime updating stuff.


Graphics Help

Post 15

DoctorMO (Keeper of the Computer, Guru, Community Artist)

I think you'll be a bit stuffed in that department. if it's unix then I have no dout the thing will be chained up two ways from sunday.

The only hope is that you have either access to an apache webserver and you could do some kindof real time displays from perl or php or another program that may beable to give you this facility.

-- DoctorMO --


Graphics Help

Post 16

MaW

It's possible to install libraries like GTK as a non-root user, but it requires a bit of trickery to actually use them unfortunately smiley - sadface

You could learn Xlib, which is likely to be available to you assuming you have access to an X system, but it's not particularly easy to use.


Graphics Help

Post 17

26199

See what libraries they already have, I guess... I certainly don't know any way to use libraries with installing 'em as root.

If it's a standard installation of something... RedHat or whatever... chances are it will already have some decent libraries. Probably.

DoctorMO... how on earth can a Linux user recommend the Windows APIs?!

That's practically an oxymoron smiley - yikes


Graphics Help

Post 18

DoctorMO (Keeper of the Computer, Guru, Community Artist)

No, recomending Linux Libaries would have been stupid. he's a windows user and programmer. i.e c++

-- DoctorMO --


Graphics Help

Post 19

Dogster

I can probably ask the staff at the department to install some libraries, supposing I did this what would you recommend? I'd still not be able to run programs that only root can run (e.g. programs that access the SVGA memory I think) though. I'll look into GTK and Xlib, and find out what they already have.


Graphics Help

Post 20

Dogster

Just checked what they have at the department, I've made a copy of the output of "ls /usr/lib/*.a" at A890732 (the /usr/local/lib directory is empty though). Would any of these be any use to me?


Key: Complain about this post