LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-13-2013, 02:17 PM   #1
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Rep: Reputation: Disabled
what include files and libraries do i need to run gtkglext in codeblocks


im trying to include libraries files into code blocks to use gtkglext but i dont know what to include can someone help me
also are their any tuts for gtkglext to get me started
thanks in advance
 
Old 05-13-2013, 02:18 PM   #2
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 396Reputation: 396Reputation: 396Reputation: 396
You should really try to do at least a little research on your own. Googling 'gtkglext example' gives plenty of good results.

Adam
 
Old 05-13-2013, 02:26 PM   #3
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
i tryed google

i have googled up to 75 pages no good results i even went to git hub but in code blocks its says /home/terrorofdeath/Downloads/adefasdf/main.c|13|fatal error:

gtk/gtkgl.h: No such file or directory

i dont know what to do
 
Old 05-13-2013, 02:34 PM   #4
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
i tried google

i have googled up to 75 pages no good results i even went to git hub but in code blocks its says /home/terrorofdeath/Downloads/adefasdf/main.c|13|fatal error:

gtk/gtkgl.h: No such file or directory

i dont know what to do
 
Old 05-13-2013, 02:37 PM   #5
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 396Reputation: 396Reputation: 396Reputation: 396
First, you only need to reply once.

Second, does /usr/include/gtkglext-1.0/gtk/gtkgl.h exist? If so, then you aren't specifying the proper include path when using the compiler. You haven't actually told us what command you are running, so we can only guess what you're doing wrong. If that file doesn't exist, then you didn't install the development package for libgtkglext.

Adam
 
Old 05-13-2013, 02:44 PM   #6
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
i used the command sudo apt-get install libgtkglext1 to install gtkglext and i included the right directory /usr/include/gtkglext-1.0/gtk inside code blocks im not sure why its not compiling properly
 
Old 05-13-2013, 02:46 PM   #7
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 396Reputation: 396Reputation: 396Reputation: 396
You didn't answer my question:

Quote:
Second, does /usr/include/gtkglext-1.0/gtk/gtkgl.h exist?
If you only insalled libgtkglext1 then you didn't actually install the development package. As I said on the previous thread, install both libgtkglext1 and libgtkglext1-dev.
 
Old 05-13-2013, 02:49 PM   #8
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
i installed both packages and /usr/include/gtkglext-1.0/gtk/gktgl.h exits maybe i need to link a library to the project or something but i dont know what to link maybe

Last edited by terrorofdeath; 05-13-2013 at 02:50 PM.
 
Old 05-13-2013, 02:51 PM   #9
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 396Reputation: 396Reputation: 396Reputation: 396
So then you aren't passing the necessary include path to the compiler, but you still haven't shown us what compiler command is getting run.

If you want help, you need to start asking intelligent questions that include all the necessary information.

In other words: show us the code, show us the command you are running and show us (if applicable) the Makefile.

Adam
 
Old 05-13-2013, 02:54 PM   #10
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
im using code blocks its says an option for linker options but im new to linux i dont know to add a makefile in here maybe you kno a link library i could try other than that i dont know what do with a makefile
 
Old 05-13-2013, 02:59 PM   #11
jkirchner
Member
 
Registered: Apr 2007
Location: West Virginia
Distribution: Ubuntu 14.04
Posts: 545

Rep: Reputation: 130Reputation: 130
What are you trying to do? Are you trying to write C or C++ code in codeblocks using the libraries you just downloaded? If yes, show the code. That is what Adamk75 has been asking for.

Have you programmed before?

Last edited by jkirchner; 05-13-2013 at 03:01 PM.
 
Old 05-13-2013, 03:02 PM   #12
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
heres the code

mybad i didnt understand the ? but heres the code

Code:
/*
 * An example of using GtkGLExt in C
 *
 * Written by Davyd Madeley <davyd@madeley.id.au> and made available under a
 * BSD license.
 *
 * This is purely an example, it may eat your cat and you can keep both pieces.
 *
 * Compile with:
 *    gcc -o gtkglext-example `pkg-config --cflags --libs gtk+-2.0 gtkglext-1.0 gtkglext-x11-1.0` gtkglext-example.c
 */

#include <gtk/gtk.h>
#include <gtk/gtkgl.h>
#include <GL/gl.h>

#include <math.h>

float boxv[][3] = {
	{ -0.5, -0.5, -0.5 },
	{  0.5, -0.5, -0.5 },
	{  0.5,  0.5, -0.5 },
	{ -0.5,  0.5, -0.5 },
	{ -0.5, -0.5,  0.5 },
	{  0.5, -0.5,  0.5 },
	{  0.5,  0.5,  0.5 },
	{ -0.5,  0.5,  0.5 }
};
#define ALPHA 0.5

static float ang = 30.;

static gboolean
expose (GtkWidget *da, GdkEventExpose *event, gpointer user_data)
{
	GdkGLContext *glcontext = gtk_widget_get_gl_context (da);
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da);

	// g_print (" :: expose\n");

	if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
	{
		g_assert_not_reached ();
	}

	/* draw in here */
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glPushMatrix();

	glRotatef (ang, 1, 0, 1);
	// glRotatef (ang, 0, 1, 0);
	// glRotatef (ang, 0, 0, 1);

	glShadeModel(GL_FLAT);

#if 0
	glBegin (GL_QUADS);
	glColor4f(0.0, 0.0, 1.0, ALPHA);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[3]);

	glColor4f(1.0, 1.0, 0.0, ALPHA);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[4]);
	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[1]);

	glColor4f(0.0, 1.0, 1.0, ALPHA);
	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[7]);
	glVertex3fv(boxv[3]);

	glColor4f(1.0, 0.0, 0.0, ALPHA);
	glVertex3fv(boxv[4]);
	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[7]);

	glColor4f(1.0, 0.0, 1.0, ALPHA);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[3]);
	glVertex3fv(boxv[7]);
	glVertex3fv(boxv[4]);

	glColor4f(0.0, 1.0, 0.0, ALPHA);
	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[2]);

	glEnd ();
#endif

	glBegin (GL_LINES);
	glColor3f (1., 0., 0.);
	glVertex3f (0., 0., 0.);
	glVertex3f (1., 0., 0.);
	glEnd ();

	glBegin (GL_LINES);
	glColor3f (0., 1., 0.);
	glVertex3f (0., 0., 0.);
	glVertex3f (0., 1., 0.);
	glEnd ();

	glBegin (GL_LINES);
	glColor3f (0., 0., 1.);
	glVertex3f (0., 0., 0.);
	glVertex3f (0., 0., 1.);
	glEnd ();

	glBegin(GL_LINES);
	glColor3f (1., 1., 1.);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[1]);

	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[2]);

	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[3]);

	glVertex3fv(boxv[3]);
	glVertex3fv(boxv[0]);

	glVertex3fv(boxv[4]);
	glVertex3fv(boxv[5]);

	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[6]);

	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[7]);

	glVertex3fv(boxv[7]);
	glVertex3fv(boxv[4]);

	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[4]);

	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[5]);

	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[6]);

	glVertex3fv(boxv[3]);
	glVertex3fv(boxv[7]);
	glEnd();

	glPopMatrix ();

	if (gdk_gl_drawable_is_double_buffered (gldrawable))
		gdk_gl_drawable_swap_buffers (gldrawable);

	else
		glFlush ();

	gdk_gl_drawable_gl_end (gldrawable);

	return TRUE;
}

static gboolean
configure (GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
{
	GdkGLContext *glcontext = gtk_widget_get_gl_context (da);
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da);

	if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
	{
		g_assert_not_reached ();
	}

	glLoadIdentity();
	glViewport (0, 0, da->allocation.width, da->allocation.height);
	glOrtho (-10,10,-10,10,-20050,10000);
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glScalef (10., 10., 10.);

	gdk_gl_drawable_gl_end (gldrawable);

	return TRUE;
}

static gboolean
rotate (gpointer user_data)
{
	GtkWidget *da = GTK_WIDGET (user_data);

	ang++;

	gdk_window_invalidate_rect (da->window, &da->allocation, FALSE);
	gdk_window_process_updates (da->window, FALSE);

	return TRUE;
}

int
main (int argc, char **argv)
{
	GtkWidget *window;
	GtkWidget *da;
	GdkGLConfig *glconfig;

	gtk_init (&argc, &argv);
	gtk_gl_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
	da = gtk_drawing_area_new ();

	gtk_container_add (GTK_CONTAINER (window), da);
	g_signal_connect_swapped (window, "destroy",
			G_CALLBACK (gtk_main_quit), NULL);
	gtk_widget_set_events (da, GDK_EXPOSURE_MASK);

	gtk_widget_show (window);

	/* prepare GL */
	glconfig = gdk_gl_config_new_by_mode (
			GDK_GL_MODE_RGB |
			GDK_GL_MODE_DEPTH |
			GDK_GL_MODE_DOUBLE);

	if (!glconfig)
	{
		g_assert_not_reached ();
	}

	if (!gtk_widget_set_gl_capability (da, glconfig, NULL, TRUE,
				GDK_GL_RGBA_TYPE))
	{
		g_assert_not_reached ();
	}

	g_signal_connect (da, "configure-event",
			G_CALLBACK (configure), NULL);
	g_signal_connect (da, "expose-event",
			G_CALLBACK (expose), NULL);

	gtk_widget_show_all (window);

	g_timeout_add (1000 / 60, rotate, da);

	gtk_main ();
}
 
Old 05-13-2013, 03:08 PM   #13
terrorofdeath
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
mybad i didn't understand the ? heres the code

Code:
#include <gtk/gtk.h>
#include <gtk/gtkgl.h>
#include <GL/gl.h>

#include <math.h>

float boxv[][3] = {
	{ -0.5, -0.5, -0.5 },
	{  0.5, -0.5, -0.5 },
	{  0.5,  0.5, -0.5 },
	{ -0.5,  0.5, -0.5 },
	{ -0.5, -0.5,  0.5 },
	{  0.5, -0.5,  0.5 },
	{  0.5,  0.5,  0.5 },
	{ -0.5,  0.5,  0.5 }
};
#define ALPHA 0.5

static float ang = 30.;

static gboolean
expose (GtkWidget *da, GdkEventExpose *event, gpointer user_data)
{
	GdkGLContext *glcontext = gtk_widget_get_gl_context (da);
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da);

	// g_print (" :: expose\n");

	if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
	{
		g_assert_not_reached ();
	}

	/* draw in here */
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glPushMatrix();

	glRotatef (ang, 1, 0, 1);
	// glRotatef (ang, 0, 1, 0);
	// glRotatef (ang, 0, 0, 1);

	glShadeModel(GL_FLAT);

#if 0
	glBegin (GL_QUADS);
	glColor4f(0.0, 0.0, 1.0, ALPHA);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[3]);

	glColor4f(1.0, 1.0, 0.0, ALPHA);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[4]);
	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[1]);

	glColor4f(0.0, 1.0, 1.0, ALPHA);
	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[7]);
	glVertex3fv(boxv[3]);

	glColor4f(1.0, 0.0, 0.0, ALPHA);
	glVertex3fv(boxv[4]);
	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[7]);

	glColor4f(1.0, 0.0, 1.0, ALPHA);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[3]);
	glVertex3fv(boxv[7]);
	glVertex3fv(boxv[4]);

	glColor4f(0.0, 1.0, 0.0, ALPHA);
	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[2]);

	glEnd ();
#endif

	glBegin (GL_LINES);
	glColor3f (1., 0., 0.);
	glVertex3f (0., 0., 0.);
	glVertex3f (1., 0., 0.);
	glEnd ();

	glBegin (GL_LINES);
	glColor3f (0., 1., 0.);
	glVertex3f (0., 0., 0.);
	glVertex3f (0., 1., 0.);
	glEnd ();

	glBegin (GL_LINES);
	glColor3f (0., 0., 1.);
	glVertex3f (0., 0., 0.);
	glVertex3f (0., 0., 1.);
	glEnd ();

	glBegin(GL_LINES);
	glColor3f (1., 1., 1.);
	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[1]);

	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[2]);

	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[3]);

	glVertex3fv(boxv[3]);
	glVertex3fv(boxv[0]);

	glVertex3fv(boxv[4]);
	glVertex3fv(boxv[5]);

	glVertex3fv(boxv[5]);
	glVertex3fv(boxv[6]);

	glVertex3fv(boxv[6]);
	glVertex3fv(boxv[7]);

	glVertex3fv(boxv[7]);
	glVertex3fv(boxv[4]);

	glVertex3fv(boxv[0]);
	glVertex3fv(boxv[4]);

	glVertex3fv(boxv[1]);
	glVertex3fv(boxv[5]);

	glVertex3fv(boxv[2]);
	glVertex3fv(boxv[6]);

	glVertex3fv(boxv[3]);
	glVertex3fv(boxv[7]);
	glEnd();

	glPopMatrix ();

	if (gdk_gl_drawable_is_double_buffered (gldrawable))
		gdk_gl_drawable_swap_buffers (gldrawable);

	else
		glFlush ();

	gdk_gl_drawable_gl_end (gldrawable);

	return TRUE;
}

static gboolean
configure (GtkWidget *da, GdkEventConfigure *event, gpointer user_data)
{
	GdkGLContext *glcontext = gtk_widget_get_gl_context (da);
	GdkGLDrawable *gldrawable = gtk_widget_get_gl_drawable (da);

	if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
	{
		g_assert_not_reached ();
	}

	glLoadIdentity();
	glViewport (0, 0, da->allocation.width, da->allocation.height);
	glOrtho (-10,10,-10,10,-20050,10000);
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glScalef (10., 10., 10.);

	gdk_gl_drawable_gl_end (gldrawable);

	return TRUE;
}

static gboolean
rotate (gpointer user_data)
{
	GtkWidget *da = GTK_WIDGET (user_data);

	ang++;

	gdk_window_invalidate_rect (da->window, &da->allocation, FALSE);
	gdk_window_process_updates (da->window, FALSE);

	return TRUE;
}

int
main (int argc, char **argv)
{
	GtkWidget *window;
	GtkWidget *da;
	GdkGLConfig *glconfig;

	gtk_init (&argc, &argv);
	gtk_gl_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
	da = gtk_drawing_area_new ();

	gtk_container_add (GTK_CONTAINER (window), da);
	g_signal_connect_swapped (window, "destroy",
			G_CALLBACK (gtk_main_quit), NULL);
	gtk_widget_set_events (da, GDK_EXPOSURE_MASK);

	gtk_widget_show (window);

	/* prepare GL */
	glconfig = gdk_gl_config_new_by_mode (
			GDK_GL_MODE_RGB |
			GDK_GL_MODE_DEPTH |
			GDK_GL_MODE_DOUBLE);

	if (!glconfig)
	{
		g_assert_not_reached ();
	}

	if (!gtk_widget_set_gl_capability (da, glconfig, NULL, TRUE,
				GDK_GL_RGBA_TYPE))
	{
		g_assert_not_reached ();
	}

	g_signal_connect (da, "configure-event",
			G_CALLBACK (configure), NULL);
	g_signal_connect (da, "expose-event",
			G_CALLBACK (expose), NULL);

	gtk_widget_show_all (window);

	g_timeout_add (1000 / 60, rotate, da);

	gtk_main ();
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Having trouble using codeblocks IDE. Quick run through? mothergoose729 Programming 26 05-24-2010 06:28 AM
[SOLVED] Codeblocks plugins and header files location konzo Programming 3 01-29-2010 11:26 PM
codeblocks doesnt run after installing updates calicratis19 Programming 2 12-08-2009 09:40 AM
X libraries or include files not found bishal Linux - Software 3 07-06-2004 01:03 PM
Why not include all necessary libraries in a release? chingasman Linux - General 3 02-03-2003 05:35 PM


All times are GMT -5. The time now is 09:39 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration