ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello. I am intersted in writing C++ progams that can display simple lines or shapes that will represent some objects. For example, a grid that looks much like a crossword puzzle and an oject that occupies one of the squares, and this object will navigate from one end of the blank squares to another.
Anyway, I figure I need some graphics capability but graphics.c is out as I'm on a linux machine.
I've been reading about openGL, MinGW for Eclipse and I have big trouble installing all this stuff correctly. I have installed Eclipse Luna and use it for Java and have the C++ CDT as well. But I don't have graphics capability. I want to draw simple two dimentional shapes.
Can you tell me what I need to install, where to install or direct me to the correct instructions please?
I have OpenSuse 13.1
For your specific use-case you probably go best with forgetting about OpenGL and just use a cross-platform toolkit, like Qt, it will give you all the capabilities you need.
I'm on a linux machine. ... I've been reading about openGL, MinGW for Eclipse...
MinGW creates Windows exes.
Quote:
I have installed Eclipse Luna and use it for Java and have the C++ CDT as well. But I don't have graphics capability. I want to draw simple two dimentional shapes.
For example, a grid that looks much like a crossword puzzle and an oject that occupies one of the squares, and this object will navigate from one end of the blank squares to another.
This sounds like some sort of game perhaps? SDL is popular library for this sort of thing. It also has some functions for setting up OpenGL surfaces, but you'll only need that for hardware accelerated 3D stuff.
Compared to Qt it's a lot smaller and simpler because it doesn't include UI widgets (buttons, text boxes, etc).
I'm a novice so I wouldn't take my advice as gospel but I am using Eclipse and Allegro 4. It's good for simple console programming and using graphics. (Similar to MS Graphics.lib) However learning from ground zero, I would suggest using Allegro 5. As I understand it, it's event driven.
Plus Allegro libraries can be used on both Linux and Windows. (I'm running a duel boot). Only thing to remember, if you want to run your game on machines without the Allegro library, you will need to compile your game with Allegro static library. In short, it makes your program bigger by including all the info needed to run your game independently.
Again, I'm not an expert, but this should be enough info to Google the gaps. And send your game once you have it.
If you want graphics capabilities in your C/C++ program, you need to use a graphics library.
But OpenGL is for 3D stuff, and GTK or Qt are for GUIs.
So, for 2D graphics: SDL, Cairo, ... (others that I can't remember at the moment.) Googling 'LibSDL' and 'Cairo graphics' should give you relevant links. Once your choice is made, all you will have to do is install the development packages and read API docs.
But OpenGL is for 3D stuff, and GTK or Qt are for GUIs.
Qt is not a GUI framework, but an application framework. It is totally possible to write Qt applications for the console, it also has widgets that allow 2D drawing and access to OpenGL.
But you are right, a specialized cross-platform library may be better here, depending on how complex the application is.
This is just a learning tool for myself. I like to see results in graphical form.
The Cairo tutorial is very well written but the program code looks like a huge learning curve for me. Oh well, it's Sunday and it's sleeting outside - might as well.
Trying to download, message says it's already installed. Now I wish I could just copy and psste a very simple program to see if it works.
Qt is not a GUI framework, but an application framework. It is totally possible to write Qt applications for the console, it also has widgets that allow 2D drawing and access to OpenGL.
I've used GTK a lot but I don't know much Qt, so my mistake. Actually, you can also do 2D drawing with GTK, mainly with cairo functions.
Quote:
Originally Posted by Birdman48
The Cairo tutorial is very well written but the program code looks like a huge learning curve for me.
Here's what I get when trying to use GTK in a C program.
Code:
jay@bird:~/CPP> gcc `pkg-config --cflags gtk+-3.0` -o window-default window-default.c `pkg-config --libs gtk+-3.0`
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk+-3.0' found
I don't know where `gtk+-3.0.pc' is nor how to add the directory to PKG_CONFIG_PATH.
EDIT: Ooops, sorry, this doesn't apply to OpenSuse. But you still need to check you have installed the dev packages. I don't know how you do that with zipper or yast.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.