Página principal | Jerarquía de la clase | Lista alfabética | Lista de componentes | Lista de archivos | Miembros de las clases | Archivos de los miembros | Páginas relacionadas

_motifglx.C

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= _motifglx.C                                       Desde octubre de 1998 =
00003 //=-------------------------------------------------------------------------=
00004 //= Definicion de elementos especificos a MOTIF                             =
00005 //=-------------------------------------------------------------------------=
00006 //= ADVERTENCIA: ESTE SOFTWARE NO ESTA CONCEBIDO NI DISENNADO PARA EL USO   =
00007 //= EN EQUIPO DE CONTROL EN LINEA EN ENTORNOS PELIGROSOS QUE REQUIERAN UN   =
00008 //= DESEMPENNO LIBRE DE FALLAS, COMO LA OPERACION DE PLANTAS NUCLEARES,     = 
00009 //= SISTEMAS DE NAVEGACION O COMUNICACION EN AVIONES, TRAFICO AEREO,        =
00010 //= EQUIPO MEDICO DEL CUAL DEPENDAN VIDAS HUMANAS O SISTEMAS DE ARMAMENTO,  =
00011 //= EN LOS CUALES UNA FALLA EN EL SOFTWARE PUEDA IMPLICAR DIRECTAMENTE LA   =
00012 //= MUERTE, DANNOS PERSONALES O DANNOS FISICOS Y/O AMBIENTALES GRAVES       =
00013 //= ("ACTIVIDADES DE ALGO RIESGO").                                         =
00014 //=-------------------------------------------------------------------------=
00015 //= Autor original: Oscar J. Chavarro G.  A.K.A. JEDILINK. Copyright (c),   =
00016 //= 1997 - 2003, oscarchavarro@hotmail.com                                  =
00017 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia   =
00018 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la  =
00019 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. =
00020 //===========================================================================
00021 
00022 #include "framework/gui/_motifglx.h"
00023 #include "framework/gui/_motifcb.h"
00024 #include "jed_gl.h"
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 
00028 #ifdef MOTIF_ENABLED
00029 
00030 //===========================================================================
00031 //= Variables globales                                                      =
00032 //===========================================================================
00033 
00034 #ifdef GL_ENABLED
00035 
00039 static int CONFIGURACION_glx_buffer_doble[] = {
00040     GLX_DOUBLEBUFFER, GLX_RGBA, GLX_DEPTH_SIZE, 16,
00041     GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1,
00042     None
00043 };
00044 static int *CONFIGURACION_glx_buffer_simple=&CONFIGURACION_glx_buffer_doble[1];
00045 #endif
00046 
00050 #ifdef GL_ENABLED
00051   GLXContext glx_context;
00052 #endif
00053 
00054 #ifdef GLX_ALTERNATIVO_NONONO
00055 GLint alloc_color(Widget w, Colormap cmap, int red, int green, int blue);
00056 void translate_pixels(Widget to, Widget from, ...);  // ?
00057 #endif
00058 
00059 #ifdef GLX_ALTERNATIVO_NONONO
00060 static GLint Black, Red, Green, Blue;
00061 #endif
00062 
00063 //===========================================================================
00064 //= Funciones de creacion y configuracion de contextos GLX                  =
00065 //===========================================================================
00066 
00067 #ifdef GLX_ALTERNATIVO_NONONO
00068 GLint
00069 alloc_color(Widget w, Colormap cmap, int red, int green, int blue)
00072 { 
00073     XColor xcolor;
00074 
00075     xcolor.red = red;
00076     xcolor.green = green;
00077     xcolor.blue = blue;
00078     xcolor.flags = DoRed | DoGreen | DoBlue;
00079     if ( !XAllocColor(XtDisplay (w), cmap, &xcolor) ) {
00080         printf ("Couldn't allocate color!\n");
00081         exit (1);
00082     }
00083     return xcolor.pixel;
00084 }
00085 
00086 void
00087 translate_pixels (Widget to, Widget from, ...)
00092 {
00093   va_list ap;
00094   char *name;
00095   Colormap from_cmap, to_cmap;
00096   XColor xcolor;
00097 
00098   XtVaGetValues (from, XtNcolormap, &from_cmap, NULL);
00099   XtVaGetValues (to, XtNcolormap, &to_cmap, NULL);
00100 
00101   va_start (ap, from);
00102   for (name = va_arg (ap, char *); name != NULL; name = va_arg (ap, char *))
00103     {
00104       XtVaGetValues (from, name, &xcolor.pixel, NULL);
00105       XQueryColor (XtDisplay (from), from_cmap, &xcolor);
00106       if (!XAllocColor (XtDisplay (to), to_cmap, &xcolor))
00107         XtAppWarning (XtWidgetToApplicationContext (to),
00108                       "Couldn't allocate color!\n");
00109       else
00110         XtVaSetValues (from, name, xcolor.pixel, NULL);
00111     }
00112   va_end (ap);
00113 }
00114 #endif
00115 
00116 //===========================================================================
00117 //= Funciones de integracion Motif/OpenGL (o lesstiff/Mesa): GLw/GLX        =
00118 //===========================================================================
00119 
00120 void
00121 arranque_GLX(Widget padre)
00132 {
00133 #ifdef GL_ENABLED
00134     Boolean rgba, doublebuffer, cmap_installed;
00135     XVisualInfo *vi;
00136     Display *Display_x;
00137 
00138     XtVaGetValues(padre,
00139         GLwNrgba, &rgba, 
00140         GLwNinstallColormap, &cmap_installed,
00141         GLwNdoublebuffer, &doublebuffer,
00142         GLwNvisualInfo, &vi, NULL);
00143 
00144     //-- Preparativos --
00145     Display_x = XtDisplay(padre);
00146 
00147     vi = glXChooseVisual(Display_x, 
00148         DefaultScreen(Display_x), CONFIGURACION_glx_buffer_doble);
00149     if ( !vi ) {
00150         vi = glXChooseVisual(Display_x, 
00151             DefaultScreen(Display_x), CONFIGURACION_glx_buffer_simple);
00152         if ( !vi ) {
00153             fprintf(stderr,
00154             "ERROR: el servidor X no soporta el modo de video solicitado!.");
00155             fflush(stderr);
00156             exit(1);
00157         }
00158     }
00159 
00160     //-- create a visual context --
00161     glx_context = glXCreateContext(Display_x, vi, None, GL_TRUE);
00162 
00163     if ( !glx_context ) {
00164         fprintf(stderr, 
00165             "<MOTIF> - ERROR: "
00166             "No se puede crear un contexto de visualizacion OpenGL.");
00167         fflush(stderr);
00168         exit(0);
00169     }
00170 
00171     GLwDrawingAreaMakeCurrent(padre, glx_context);
00172 
00173     //- Capturar la atencion del cursor y del usuario! ---------------------
00174     XWarpPointer(XtDisplay(padre), None, XtWindow (padre),0, 0, 0, 0, 0, 0);
00175 
00176   #ifdef GLX_ALTERNATIVO_NONONO
00177     if ( rgba ) {
00178         Black = Red = Green = Blue = 0;
00179 
00180         if ( cmap_installed ) {
00181            /* In RGBA mode, the Mesa widgets will have their own color map.
00182               Adjust the colors of the other widgets so that--even if the rest
00183               of the screen has wrong colors--all application widgets have the
00184               right colors.  */
00185             translate_pixels (padre, form, XtNbackground, XtNborder, NULL);
00186             translate_pixels (padre, menubar,
00187                             XmNbackground, XmNforeground, XmNborderColor, 
00188                             XmNarmColor, XmNbottomShadowColor, 
00189                             XmNtopShadowColor, NULL);
00190 
00191           /* Finally warp the pointer into the mesa widget, to make sure that
00192              the user sees the right colors at the beginning.  */
00193           XWarpPointer (XtDisplay (padre), None, XtWindow (padre),
00194                         0, 0, 0, 0, 0, 0);
00195         }
00196       }
00197       else {
00198         /* Allocate a few colors for use in color index mode.  */
00199         Colormap cmap;
00200         cmap = DefaultColormap(
00201             XtDisplay(toplevel), DefaultScreen (XtDisplay (toplevel)));
00202         Black = alloc_color (toplevel, cmap, 0x0000, 0x0000, 0x0000);
00203         Red   = alloc_color (toplevel, cmap, 0xffff, 0x0000, 0x0000);
00204         Green = alloc_color (toplevel, cmap, 0x0000, 0xffff, 0x0000);
00205         Blue  = alloc_color (toplevel, cmap, 0x0000, 0x0000, 0xffff);
00206     }
00207   #endif
00208     
00209     static BOOLEAN ya = FALSE;
00210     if ( !ya ) {
00211         motif_starttimer_callback(padre); ya = TRUE;
00212     }
00213 #endif
00214 }
00215 
00216 #endif // MOTIF_ENABLED
00217 
00218 //===========================================================================
00219 //= EOF                                                                     =
00220 //===========================================================================
00221 

Este archivo HTML ha sido generado automáticamente a partir del código fuente AQUYNZA. NO LO EDITE. Para mayor información contacte al autor.