The driver now compiles correctly without any x headers or libraries installed
authorSean D'Epagnier <geckosenator@freedesktop.org>
Fri, 18 Aug 2006 10:38:15 +0000 (10:38 +0000)
committerSean D'Epagnier <geckosenator@freedesktop.org>
Fri, 18 Aug 2006 10:38:15 +0000 (10:38 +0000)
The bitmap and stroke code can't be shared with glx anymore because of this.

The model for the mini teapot is restored and I have tested it to work with
linux-fbdev and linux-solo

The driver recognizes 32bpp where there is no alpha (my radeon 7500)  It also
sets the correct number of cmap entrees (instead of 256 which can be an error)

configs/linux-fbdev
src/glut/fbdev/Makefile
src/glut/fbdev/bitmap.c [new file with mode: 0644]
src/glut/fbdev/colormap.c
src/glut/fbdev/cursor.c
src/glut/fbdev/fbdev.c
src/glut/fbdev/stroke.c [new file with mode: 0644]
src/glut/mini/teapot.c
src/mesa/Makefile
src/mesa/drivers/fbdev/glfbdev.c

index d1aeda555ef524e7d250afc4b7754552a13bc19f..3ab6b69c39ccb69743a9217d45ff6a84f9ac7b13 100644 (file)
@@ -3,12 +3,14 @@
 include $(TOP)/configs/linux
 
 CONFIG_NAME = linux-fbdev
-DRIVER_DIRS = fbdev osmesa
-SRC_DIRS = mesa glu glut/fbdev glw
 
-CFLAGS = -g -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -DUSE_GLFBDEV_DRIVER
+CFLAGS = -O3 -ffast-math -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS -DUSE_GLFBDEV_DRIVER
 
 
+SRC_DIRS = mesa glu glut/fbdev
+DRIVER_DIRS = fbdev
+PROGRAM_DIRS = fbdev demos redbook samples
+
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread
 GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lgpm -lm
 
-PROGRAM_DIRS = fbdev demos redbook samples
index 4f70efe27946ddffed80efc66a1b69b550de0937..11d95665adbf68f965235d1a1770d17a01ae4ee6 100644 (file)
@@ -4,10 +4,10 @@ TOP = ../../..
 include $(TOP)/configs/current
 
 GLX_SHARED = $(TOP)/src/glut/glx
-SHAPES = $(TOP)/src/glut/mini
+MINI_SHARED = $(TOP)/src/glut/mini
 
-GLUT_MAJOR = 5
-GLUT_MINOR = 0
+GLUT_MAJOR = 3
+GLUT_MINOR = 7
 GLUT_TINY = 1
 
 INCLUDES = -I$(TOP)/include -I$(GLX_SHARED)
@@ -23,13 +23,13 @@ CORE_SOURCES = \
        input.c \
        callback.c \
        gamemode.c \
-       vidresize.c
+       vidresize.c \
+       bitmap.c \
+       stroke.c
 
 GLX_SHARED_SOURCES = \
        $(GLX_SHARED)/glut_8x13.c \
        $(GLX_SHARED)/glut_9x15.c \
-       $(GLX_SHARED)/glut_bwidth.c \
-       $(GLX_SHARED)/glut_bitmap.c \
        $(GLX_SHARED)/glut_hel10.c \
        $(GLX_SHARED)/glut_hel12.c \
        $(GLX_SHARED)/glut_hel18.c \
@@ -37,12 +37,12 @@ GLX_SHARED_SOURCES = \
        $(GLX_SHARED)/glut_tr24.c \
        $(GLX_SHARED)/glut_mroman.c \
        $(GLX_SHARED)/glut_roman.c \
-       $(GLX_SHARED)/glut_swidth.c \
-       $(GLX_SHARED)/glut_stroke.c \
-       $(TOP)/src/glut/mini/models.c \
-       $(GLX_SHARED)/glut_teapot.c
 
-SOURCES = $(CORE_SOURCES)  $(GLX_SHARED_SOURCES)
+MINI_SHARED_SOURCES = \
+       $(MINI_SHARED)/models.c \
+       $(MINI_SHARED)/teapot.c
+
+SOURCES = $(CORE_SOURCES)  $(GLX_SHARED_SOURCES) $(MINI_SHARED_SOURCES)
 
 OBJECTS =  $(SOURCES:.c=.o)
 
@@ -50,7 +50,7 @@ OBJECTS =  $(SOURCES:.c=.o)
 ##### RULES #####
 
 .c.o:
-       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES)  $< -o $@
 
 .S.o:
        $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES)  $< -o $@
@@ -68,6 +68,12 @@ $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
                $(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
                $(MKLIB_OPTIONS) $(OBJECTS)
 
+install:
+       $(INSTALL) -d $(INSTALL_DIR)/include/GL
+       $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
+       $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
+       $(COPY_LIBS) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
+
 # Run 'make -f Makefile.solo dep' to update the dependencies if you change
 # what's included by any source file.
 depend: $(SOURCES) 
diff --git a/src/glut/fbdev/bitmap.c b/src/glut/fbdev/bitmap.c
new file mode 100644 (file)
index 0000000..5dbb330
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  6.5
+ * Copyright (C) 1995-2006  Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*
+ * Library for glut using mesa fbdev driver
+ *
+ * Written by Sean D'Epagnier (c) 2006
+ * 
+ * To improve on this library, maybe support subwindows or overlays,
+ * I (sean at depagnier dot com) will do my best to help.
+ */
+
+
+#include "glutbitmap.h"
+
+void glutBitmapCharacter(GLUTbitmapFont font, int c)
+{
+   const BitmapCharRec *ch;
+   BitmapFontPtr fi = (BitmapFontPtr) font;
+
+   if (c < fi->first ||
+       c >= fi->first + fi->num_chars)
+      return;
+   ch = fi->ch[c - fi->first];
+   if (!ch)
+      return;
+
+   glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
+
+   glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
+   glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
+   glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+   glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+   glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+   glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 
+   glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
+           ch->advance, 0, ch->bitmap);
+   glPopClientAttrib();
+}
+
+int glutBitmapWidth (GLUTbitmapFont font, int c)
+{
+   const BitmapCharRec *ch;
+   BitmapFontPtr fi = (BitmapFontPtr) font;
+
+   if (c < fi->first || c >= fi->first + fi->num_chars)
+      return 0;
+   ch = fi->ch[c - fi->first];
+   if (ch)
+      return ch->advance;
+   return 0;
+}
+
+int glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
+{
+   int length = 0;
+
+   for (; *string; string++)
+      length += glutBitmapWidth(font, *string);
+   return length;
+}
index 157296d15c1fadd4734b37c8f631f31cf76e58a3..4c013c7646345bfb44cd6d1f5b7942fe7059164a 100644 (file)
@@ -100,8 +100,21 @@ void LoadColorMap(void)
    /* we're assuming 256 entries here */
    int i;
 
+   switch(VarInfo.bits_per_pixel) {
+   case 8:
+   case 24:
+   case 32:
+      ColorMap.len = 256;
+      break;
+   case 15:
+      ColorMap.len = 32;
+      break;
+   case 16:
+      ColorMap.len = 64;
+      break;
+   }
+
    ColorMap.start = 0;
-   ColorMap.len = 256;
    ColorMap.red   = RedColorMap;
    ColorMap.green = GreenColorMap;
    ColorMap.blue  = BlueColorMap;
index 06ae2d6f54eb8998d9a2e4831afb69778db0e26e..e7fb00f46fff3f38d1234a4b737568bfa0e9c931 100644 (file)
@@ -163,7 +163,8 @@ void DrawCursor(void)
         cstride /= 2;
         for(i = yoff; i < ylen; i++) {
            for(j = xoff; j < xlen; j++) {
-              e[0] = ((((d[0] + (((int)(((e[0] >> 8) & 0xf8) 
+              if(d[3] < 220)
+                 e[0] = ((((d[0] + (((int)(((e[0] >> 8) & 0xf8) 
                         | ((c[0] >> 11) & 0x7)) * d[3]) >> 8)) & 0xf8) << 8)
                     | (((d[1] + (((int)(((e[0] >> 3) & 0xfc)
                         | ((e[0] >> 5) & 0x3)) * d[3]) >> 8)) & 0xfc) << 3)
@@ -181,9 +182,11 @@ void DrawCursor(void)
    case 4:
       for(i = yoff; i < ylen; i++) {
         for(j = xoff; j < xlen; j++) {
-           c[0] = d[0] + (((int)c[0] * d[3]) >> 8);
-           c[1] = d[1] + (((int)c[1] * d[3]) >> 8);
-           c[2] = d[2] + (((int)c[2] * d[3]) >> 8);
+           if(d[3] < 220) {
+              c[0] = d[0] + (((int)c[0] * d[3]) >> 8);
+              c[1] = d[1] + (((int)c[1] * d[3]) >> 8);
+              c[2] = d[2] + (((int)c[2] * d[3]) >> 8);
+           }
                
            c+=bypp;
            d+=4;
index ce7d187b66dba9e5794ee1a62cb370c965e7dcfd..10bc6eacc147d619b917d85547c87cd38c643d5c 100644 (file)
@@ -112,11 +112,8 @@ static void Cleanup(void)
    /* close mouse */
    CloseMouse();
 
-   glFBDevMakeCurrent( NULL, NULL, NULL);
-
-   glFBDevDestroyContext(Context);
-   glFBDevDestroyBuffer(Buffer);
-   glFBDevDestroyVisual(Visual);
+   if(Visual)
+      glutDestroyWindow(1);
 
    /* restore original variable screen info */
    if(FrameBufferFD != -1) {
@@ -735,6 +732,11 @@ int glutGetWindow(void)
 
 void glutDestroyWindow(int win)
 {
+   glFBDevMakeCurrent( NULL, NULL, NULL);
+   glFBDevDestroyContext(Context);
+   glFBDevDestroyBuffer(Buffer);
+   glFBDevDestroyVisual(Visual);
+   Visual = NULL;
 }
 
 void glutPostRedisplay(void)
@@ -762,6 +764,7 @@ void glutSwapBuffers(void)
       Swapping = 0;
    }
 
+   /* if there was a vt switch while swapping, switch now */
    if(VTSwitch) {
       if(ioctl(ConsoleFD, VT_ACTIVATE, VTSwitch) < 0)
         sprintf(exiterror, "Error switching console\n");
diff --git a/src/glut/fbdev/stroke.c b/src/glut/fbdev/stroke.c
new file mode 100644 (file)
index 0000000..1943ac6
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  6.5
+ * Copyright (C) 1995-2006  Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*
+ * Library for glut using mesa fbdev driver
+ *
+ * Written by Sean D'Epagnier (c) 2006
+ * 
+ * To improve on this library, maybe support subwindows or overlays,
+ * I (sean at depagnier dot com) will do my best to help.
+ */
+
+#include <GL/glut.h>
+#include "glutstroke.h"
+
+void glutStrokeCharacter(GLUTstrokeFont font, int c)
+{
+   const StrokeCharRec *ch;
+   const StrokeRec *stroke;
+   const CoordRec *coord;
+   StrokeFontPtr fontinfo = (StrokeFontPtr) font;
+   int i, j;
+
+   if (c < 0 || c >= fontinfo->num_chars)
+      return;
+   ch = &(fontinfo->ch[c]);
+   if (ch) {
+      for (i = ch->num_strokes, stroke = ch->stroke;
+          i > 0; i--, stroke++) {
+        glBegin(GL_LINE_STRIP);
+        for (j = stroke->num_coords, coord = stroke->coord;
+             j > 0; j--, coord++) {
+           glVertex2f(coord->x, coord->y);
+        }
+        glEnd();
+      }
+      glTranslatef(ch->right, 0.0, 0.0);
+   }
+}
+
+int glutStrokeWidth(GLUTstrokeFont font, int c)
+{
+   StrokeFontPtr fontinfo;
+   const StrokeCharRec *ch;
+
+   fontinfo = (StrokeFontPtr) font;
+
+   if (c < 0 || c >= fontinfo->num_chars)
+      return 0;
+   ch = &(fontinfo->ch[c]);
+   if (ch)
+      return ch->right;
+
+   return 0;
+}
+
+int glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
+{
+   int length = 0;
+
+   for (; *string; string++)
+      length += glutStrokeWidth(font, *string);
+   return length;
+}
index ec2a207763e919a63d3969a8ce7800f9fcd6088c..aa96fcbbbd625a2d9d7d583acfac31fe7244d0d6 100644 (file)
@@ -143,7 +143,6 @@ teapot(GLint grid, GLdouble scale, GLenum type)
   float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
   long i, j, k, l;
 
-#if 0
   glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
   glEnable(GL_AUTO_NORMAL);
   glEnable(GL_NORMALIZE);
@@ -195,7 +194,6 @@ teapot(GLint grid, GLdouble scale, GLenum type)
   }
   glPopMatrix();
   glPopAttrib();
-#endif
 }
 
 /* CENTRY */
index bf600e0578d8f5b8624841b9fd47fac78316429e..16cf6709ea5c4ec0f740e8c01346647d7b022c49 100644 (file)
@@ -38,7 +38,6 @@ default:
        fi
 
 
-
 ######################################################################
 # BeOS driver target
 
@@ -74,13 +73,17 @@ directfb: depend subdirs libgl-core
 
 ######################################################################
 # Stand-alone Mesa libGL and libOSMesa
-
-STAND_ALONE_DRIVER_SOURCES = \
+STAND_ALONE_DRIVER_SOURCES_A = \
        $(COMMON_DRIVER_SOURCES) \
-       $(X11_DRIVER_SOURCES) \
        $(GLIDE_DRIVER_SOURCES) \
-       $(SVGA_DRIVER_SOURCES) \
-       $(FBDEV_DRIVER_SOURCES)
+       $(SVGA_DRIVER_SOURCES)
+
+# if x11 is not installed, compiling with x11 sources will not work for fbdev
+ifeq ($(DRIVER_DIRS), fbdev)
+STAND_ALONE_DRIVER_SOURCES = $(STAND_ALONE_DRIVER_SOURCES_A) $(FBDEV_DRIVER_SOURCES)
+else
+STAND_ALONE_DRIVER_SOURCES = $(STAND_ALONE_DRIVER_SOURCES_A) $(X11_DRIVER_SOURCES)
+endif
 
 STAND_ALONE_DRIVER_OBJECTS = $(STAND_ALONE_DRIVER_SOURCES:.c=.o)
 
@@ -133,6 +136,7 @@ ALL_SOURCES = \
        $(X86_SOURCES)          \
        $(COMMON_DRIVER_SOURCES)\
        $(X11_DRIVER_SOURCES)   \
+       $(FBDEV_DRIVER_SOURCES) \
        $(OSMESA_DRIVER_SOURCES)
 
 
index 21b6165bb14e31dee6e8946599211799dcf01c86..3a6b452065bb0f76215f20c19c22056280e947d7 100644 (file)
@@ -152,8 +152,8 @@ static void
 get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
 {
    const GLFBDevBufferPtr fbdevbuffer = GLFBDEV_BUFFER(buffer);
-   *width = fbdevbuffer->var.xres_virtual;
-   *height = fbdevbuffer->var.yres_virtual;
+   *width = fbdevbuffer->var.xres;
+   *height = fbdevbuffer->var.yres;
 }
 
 
@@ -389,43 +389,37 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo,
       blueBits  = varInfo->blue.length;
       alphaBits = varInfo->transp.length;
 
-      if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
-           fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
-          && varInfo->bits_per_pixel == 24
-          && varInfo->red.offset == 16
-          && varInfo->green.offset == 8
-          && varInfo->blue.offset == 0) {
-         vis->pixelFormat = PF_B8G8R8;
-      }
-      else if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
-                fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
-               && varInfo->bits_per_pixel == 32
-               && varInfo->red.offset == 16
-               && varInfo->green.offset == 8
-               && varInfo->blue.offset == 0
-               && varInfo->transp.offset == 24) {
-         vis->pixelFormat = PF_B8G8R8A8;
-      }
-      else if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
-                fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
-               && varInfo->bits_per_pixel == 16
-               && varInfo->red.offset == 11
-               && varInfo->green.offset == 5
-               && varInfo->blue.offset == 0) {
-         vis->pixelFormat = PF_B5G6R5;
-      }
-      else if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
-                fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
-               && varInfo->bits_per_pixel == 16
-               && varInfo->red.offset == 10
-               && varInfo->green.offset == 5
-               && varInfo->blue.offset == 0) {
-         vis->pixelFormat = PF_B5G5R5;
-      }
-      else {
-         _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n");
-         _mesa_free(vis);
-         return NULL;
+      if (fixInfo->visual == FB_VISUAL_TRUECOLOR ||
+         fixInfo->visual == FB_VISUAL_DIRECTCOLOR) {
+        if(varInfo->bits_per_pixel == 24
+           && varInfo->red.offset == 16
+           && varInfo->green.offset == 8
+           && varInfo->blue.offset == 0)
+           vis->pixelFormat = PF_B8G8R8;
+
+        else if(varInfo->bits_per_pixel == 32
+                && varInfo->red.offset == 16
+                && varInfo->green.offset == 8
+                && varInfo->blue.offset == 0)
+           vis->pixelFormat = PF_B8G8R8A8;
+
+        else if(varInfo->bits_per_pixel == 16
+                && varInfo->red.offset == 11
+                && varInfo->green.offset == 5
+                && varInfo->blue.offset == 0)
+           vis->pixelFormat = PF_B5G6R5;
+
+        else if(varInfo->bits_per_pixel == 16
+                && varInfo->red.offset == 10
+                && varInfo->green.offset == 5
+                && varInfo->blue.offset == 0)
+           vis->pixelFormat = PF_B5G5R5;
+
+        else {
+           _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n");
+           _mesa_free(vis);
+           return NULL;
+        }
       }
    }
    else {
@@ -568,7 +562,7 @@ new_glfbdev_renderbuffer(void *bufferStart, const GLFBDevVisualPtr visual)
 
       rb->rowStride = visual->var.xres_virtual * visual->var.bits_per_pixel / 8;
       rb->bottom = (GLubyte *) bufferStart
-         + (visual->var.yres_virtual - 1) * rb->rowStride;
+         + (visual->var.yres - 1) * rb->rowStride;
 
       rb->Base.Width = visual->var.xres;
       rb->Base.Height = visual->var.yres;