summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean D'Epagnier <geckosenator@freedesktop.org>2006-08-18 10:38:15 +0000
committerJosé Fonseca <jfonseca@vmware.com>2011-07-11 20:03:34 +0100
commitcf8cb1c55fc3924f2dacb09988523145c405004a (patch)
treec2e65e1b00298ecef981d23779706ac2ae3b1fac
parent25365be75946b93c2e987bf1d46fa3d473d4c1f6 (diff)
downloadglut-cf8cb1c55fc3924f2dacb09988523145c405004a.tar.gz
The driver now compiles correctly without any x headers or libraries installed 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)
-rw-r--r--src/glut/fbdev/Makefile30
-rw-r--r--src/glut/fbdev/bitmap.c78
-rw-r--r--src/glut/fbdev/colormap.c15
-rw-r--r--src/glut/fbdev/cursor.c11
-rw-r--r--src/glut/fbdev/fbdev.c13
-rw-r--r--src/glut/fbdev/stroke.c81
-rw-r--r--src/glut/mini/teapot.c2
7 files changed, 206 insertions, 24 deletions
diff --git a/src/glut/fbdev/Makefile b/src/glut/fbdev/Makefile
index 4f70efe..11d9566 100644
--- a/src/glut/fbdev/Makefile
+++ b/src/glut/fbdev/Makefile
@@ -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
index 0000000..5dbb330
--- /dev/null
+++ b/src/glut/fbdev/bitmap.c
@@ -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;
+}
diff --git a/src/glut/fbdev/colormap.c b/src/glut/fbdev/colormap.c
index 157296d..4c013c7 100644
--- a/src/glut/fbdev/colormap.c
+++ b/src/glut/fbdev/colormap.c
@@ -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;
diff --git a/src/glut/fbdev/cursor.c b/src/glut/fbdev/cursor.c
index 06ae2d6..e7fb00f 100644
--- a/src/glut/fbdev/cursor.c
+++ b/src/glut/fbdev/cursor.c
@@ -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;
diff --git a/src/glut/fbdev/fbdev.c b/src/glut/fbdev/fbdev.c
index ce7d187..10bc6ea 100644
--- a/src/glut/fbdev/fbdev.c
+++ b/src/glut/fbdev/fbdev.c
@@ -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
index 0000000..1943ac6
--- /dev/null
+++ b/src/glut/fbdev/stroke.c
@@ -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;
+}
diff --git a/src/glut/mini/teapot.c b/src/glut/mini/teapot.c
index ec2a207..aa96fcb 100644
--- a/src/glut/mini/teapot.c
+++ b/src/glut/mini/teapot.c
@@ -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 */