LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-28-2015, 06:53 AM   #1
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Rep: Reputation: 1
Eclipse, OpenGL, MinGW?


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
 
Old 02-28-2015, 08:03 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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.
 
Old 02-28-2015, 09:52 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,786

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by Birdman48 View Post
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.
Do you specifically want graphics in C++? Because you could do this in Java: http://docs.oracle.com/javase/7/docs...raphics2D.html

Quote:
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).
 
Old 02-28-2015, 10:11 AM   #4
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 345

Rep: Reputation: 54
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.

Good Luck
Ace
 
Old 03-01-2015, 11:47 AM   #5
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
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.

Last edited by manu-tm; 03-01-2015 at 11:53 AM.
 
Old 03-01-2015, 11:51 AM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by manu-tm View Post
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.
 
Old 03-01-2015, 12:04 PM   #7
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Original Poster
Rep: Reputation: 1
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.

Last edited by Birdman48; 03-01-2015 at 12:35 PM.
 
Old 03-01-2015, 12:37 PM   #8
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
Quote:
Originally Posted by TobiSGD View Post
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 View Post
The Cairo tutorial is very well written but the program code looks like a huge learning curve for me.
SDL is more low-level and simpler.

Last edited by manu-tm; 03-01-2015 at 12:55 PM.
 
Old 03-01-2015, 01:35 PM   #9
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Original Poster
Rep: Reputation: 1
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.
 
Old 03-01-2015, 01:40 PM   #10
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
Have you installed the gtk3 dev packages?
Code:
sudo apt-get install libgtk-3-dev
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.

Last edited by manu-tm; 03-01-2015 at 03:01 PM.
 
Old 03-01-2015, 03:09 PM   #11
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Original Poster
Rep: Reputation: 1
yes I have those.
 
Old 03-01-2015, 03:30 PM   #12
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
What's the output of
Code:
pkg-config --cflags --libs gtk+-3.0
?
 
Old 03-01-2015, 05:55 PM   #13
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Original Poster
Rep: Reputation: 1
Quote:
jay@bird:~/CPP> pkg-config --cflags --libs gtk+-3.0
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pkg/wayland -I/usr/include/pkg/libxkbcommon -I/usr/include/pkg/wayland -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
Yeah they weren't installed after all - I just installed them, but I still get compilation error trying to compile:

Quote:
jay@bird:~/CPP> gcc -o window-default window-default.c
window-default.c:1:21: fatal error: gtk/gtk.h: No such file or directory
#include <gtk/gtk.h>
^
compilation terminated.

Last edited by Birdman48; 03-01-2015 at 05:56 PM. Reason: adding info
 
Old 03-01-2015, 05:57 PM   #14
Birdman48
Member
 
Registered: Aug 2008
Location: Southern Maryland
Distribution: ubuntu 14.04 LTS
Posts: 113

Original Poster
Rep: Reputation: 1
Here's the program I'm trying to run:
Quote:
#include <gtk/gtk.h>

int
main (int argc,char *argv[])
{
GtkWidget *window;

gtk_init (&argc, &argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

gtk_widget_show (window);

gtk_main ();

return 0;
}

Last edited by Birdman48; 03-01-2015 at 06:10 PM.
 
Old 03-01-2015, 06:14 PM   #15
manu-tm
Member
 
Registered: May 2008
Location: France
Distribution: Ubuntu, Debian
Posts: 343

Rep: Reputation: 43
Code:
jay@bird:~/CPP> gcc -o window-default window-default.c
window-default.c:1:21: fatal error: gtk/gtk.h: No such file or directory
#include <gtk/gtk.h>
^
compilation terminated.
Code:
gcc -o window-default window-default.c `pkg-config --cflags --libs gtk+-3.0`

Last edited by manu-tm; 03-01-2015 at 06:22 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Slackware14: Audio, OpenGL and Eclipse problems Edmis Linux - Newbie 1 04-22-2013 06:08 AM
Eclipse mp3 player model type: ECLIPSE-CL2BLK Bagatelle Linux - Newbie 0 12-25-2009 01:39 PM
best distribution for me - for C/C++ 3D OpenGL GLSL [eclipse IDE/CDT] maxreason Linux - General 47 08-23-2008 08:20 PM
your opinion: eclipse vs anjunta vs kdevelop vs younameit for large C++ OpenGL app maxreason Programming 20 08-20-2008 07:16 AM
LXer: Gentleware Unveils New Apollo for Eclipse and openArchitectureWare Eclipse Dist LXer Syndicated Linux News 0 10-25-2007 09:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration