Re: [gtk-list] gtkGL
- From: kenelson ece ucdavis edu
- To: gtk-list redhat com
- cc: Robert Sim <simra Intrepid McRCIM McGill EDU>
- Subject: Re: [gtk-list] gtkGL
- Date: Wed, 10 Jun 1998 12:27:07 -0700 (PDT)
-----
Robert Sim writes:
>Hi,
>
>I'm in the midst of porting an Xt app to gtk- using a gtkGL drawable
>w/ Mesa. I have some questions about gtkGL, for anyone who's played
>with it:
I tried it, but thought it was horribly overdesigned and that its
macros were nonportable to C++. So I am working off of gtkglarea.
But the info from that should carry over.
You might want to check through gtkglarea for yourself ...
GtkGLArea home page http://www.student.oulu.fi/~jlof/gtkglarea/
Gtk-- wrapper http://www.ece.ucdavis.edu/~kenelson/gtk-glarea/
>
>1. Can I mix gdk draw commands w/ the GL calls? If so, can they take
>place inside the GTK_GL_..._BEGIN(..) .. END wrapper?
This is a really bad idea, the gdk drawing calls write directly to
the xwindow. While the GL calls go to an internal buffer, that isn't
drawn until swap is called. Mixing the two would give bad results.
Generally you shouldn't call any x calls in the same window as
GL is working. If you were to try it, do the calls after the
swap but probably within its own seperate begin/end pair. (hoping
that it will get the right colormap.)
>
>2. Is thare any way to convert from an X named colour (eg
>"DarkSlateGray") to either a RGB representation (preferred) a la GL,
>or a gdk color? On this point, I know very little about what is
>possible- the gdk docs are pretty scanty, and I've never tried to go
>between X named colors and gl colors.
>
I actually have some code for that. (It wasn't easy.) To do it
well you need to use cms colors, but that isn't ported into gdk yet.
(Is anyone working on this? Or was it decided against it at some
point?)
Its in gtkglarea notation so you will have to translate yourself.
(Only relievent parts are shown, some code stolen from Janne Lof)
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xcms.h>
.
.
.
gint draw(GtkWidget *widget, GdkEventExpose *event)
{
XcmsColor exact, closest;
GdkColormap *cmap=gtk_widget_get_colormap(widget);
/* Draw only last expose. */
if (event->count > 0) {
return TRUE;
}
/* OpenGL functions can be called only if gtk_gl_area_begingl
returns true, you can't call gl* functions anywhere except
inside gtk_gl_area_begingl()/gtk_gl_area_endgl() pairs.
*/
if (gtk_gl_area_begingl(GTK_GL_AREA(widget))) {
/* Draw simple triangle */
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
/* Make a color lookup */
XcmsLookupColor(GDK_DISPLAY(),
GDK_COLORMAP_XCOLORMAP(cmap),"SlateBlue",
&exact,&closest,XcmsRGBiFormat);
glColor3f(exact.spec.RGBi.red,exact.spec.RGBi.green,exact.spec.RGBi.blue);
glBegin(GL_TRIANGLES);
glVertex2f(10,10);
glVertex2f(10,90);
glVertex2f(90,90);
glEnd();
/* Opengl rendering is done for now. */
gtk_gl_area_endgl(GTK_GL_AREA(widget));
}
/* Swap backbuffer to front */
gtk_gl_area_swapbuffers(GTK_GL_AREA(widget));
return TRUE;
}
>Thanks,
>R
>
Hope it helps.
-- Karl Nelson
kenelson@ece.ucdavis.edu
http://www.ece.ucdavis.edu/~kenelson/gtk-glarea
Ey coudn't spel efin iv mi lief deependid un et.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]