From 5bcbdec97c7b247ad76eae8861bece1c4d601979 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Mon, 6 Sep 2010 12:58:02 +0000 Subject: [PATCH] Currently attempting to export an OpenGL-enabled display --- Makefile | 7 +- config.h | 10 +++ data/GServer.interface | 54 +++++++++++++ data/Makefile | 21 +++++ data/project.conf | 4 + project.conf | 5 +- src/Makefile | 19 +++-- src/appbroker.sh | 20 +++++ src/gserver.c | 172 ++++++++++++++++++++++++++++++++++++++--- src/gserver.h | 11 +++ src/main.c | 11 +++ src/project.conf | 15 ++-- src/video/Makefile | 28 +++++-- src/video/glx.c | 162 ++++++++++++++++++++++++++++++++++++++ src/video/project.conf | 17 +++- src/video/vbe.h | 21 ++++- src/video/vesa.c | 30 +++++-- src/video/video.h | 26 +++++-- 18 files changed, 580 insertions(+), 53 deletions(-) create mode 100644 config.h create mode 100644 data/GServer.interface create mode 100644 data/Makefile create mode 100644 data/project.conf create mode 100755 src/appbroker.sh create mode 100644 src/video/glx.c diff --git a/Makefile b/Makefile index 851ef2b..d52e4a5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ PACKAGE = GServer VERSION = 0.0.0 -SUBDIRS = src +SUBDIRS = data src RM = rm -f LN = ln -f TAR = tar -czvf @@ -21,11 +21,15 @@ dist: $(RM) -r -- $(PACKAGE)-$(VERSION) $(LN) -s -- . $(PACKAGE)-$(VERSION) @$(TAR) $(PACKAGE)-$(VERSION).tar.gz -- \ + $(PACKAGE)-$(VERSION)/data/Makefile \ + $(PACKAGE)-$(VERSION)/data/GServer.interface \ + $(PACKAGE)-$(VERSION)/data/project.conf \ $(PACKAGE)-$(VERSION)/src/gserver.c \ $(PACKAGE)-$(VERSION)/src/main.c \ $(PACKAGE)-$(VERSION)/src/Makefile \ $(PACKAGE)-$(VERSION)/src/gserver.h \ $(PACKAGE)-$(VERSION)/src/project.conf \ + $(PACKAGE)-$(VERSION)/src/video/glx.c \ $(PACKAGE)-$(VERSION)/src/video/vbe.c \ $(PACKAGE)-$(VERSION)/src/video/vesa.c \ $(PACKAGE)-$(VERSION)/src/video/Makefile \ @@ -35,6 +39,7 @@ dist: $(PACKAGE)-$(VERSION)/COPYING \ $(PACKAGE)-$(VERSION)/Makefile \ $(PACKAGE)-$(VERSION)/TODO \ + $(PACKAGE)-$(VERSION)/config.h \ $(PACKAGE)-$(VERSION)/project.conf $(RM) -- $(PACKAGE)-$(VERSION) diff --git a/config.h b/config.h new file mode 100644 index 0000000..92e95fa --- /dev/null +++ b/config.h @@ -0,0 +1,10 @@ +#define PACKAGE "GServer" +#define VERSION "0.0.0" + +#ifndef PREFIX +# define PREFIX "/usr/local" +#endif + +#ifndef LIBDIR +# define LIBDIR PREFIX "/lib" +#endif diff --git a/data/GServer.interface b/data/GServer.interface new file mode 100644 index 0000000..8d884d4 --- /dev/null +++ b/data/GServer.interface @@ -0,0 +1,54 @@ +service=GServer +port=4248 + +[glBegin] +arg1=UINT32 + +[glClear] +arg1=UINT32 + +[glClearColor] +arg1=FLOAT +arg2=FLOAT +arg3=FLOAT +arg4=FLOAT + +[glClearDepth] +arg1=DOUBLE + +[glColor3f] +arg1=FLOAT +arg2=FLOAT +arg3=FLOAT + +[glColor3i] +arg1=INT32 +arg2=INT32 +arg3=INT32 + +[glEnd] +ret=void + +[glFlush] +ret=void + +[glLoadIdentity] +ret=void + +[glTranslatef] +arg1=FLOAT +arg2=FLOAT +arg3=FLOAT + +[glVertex3f] +arg1=FLOAT +arg2=FLOAT +arg3=FLOAT + +[glVertex3i] +arg1=INT32 +arg2=INT32 +arg3=INT32 + +[SwapBuffers] +ret=void diff --git a/data/Makefile b/data/Makefile new file mode 100644 index 0000000..0fa3dfa --- /dev/null +++ b/data/Makefile @@ -0,0 +1,21 @@ +PREFIX = /usr/local +DESTDIR = +MKDIR = mkdir -p +INSTALL = install +RM = rm -f + + +all: + +clean: + +distclean: clean + +install: all + $(MKDIR) $(DESTDIR)$(PREFIX)/etc/AppInterface + $(INSTALL) -m 0644 -- GServer.interface $(DESTDIR)$(PREFIX)/etc/AppInterface/GServer.interface + +uninstall: + $(RM) -- $(DESTDIR)$(PREFIX)/etc/AppInterface/GServer.interface + +.PHONY: all clean distclean install uninstall diff --git a/data/project.conf b/data/project.conf new file mode 100644 index 0000000..c1107d5 --- /dev/null +++ b/data/project.conf @@ -0,0 +1,4 @@ +dist=Makefile,GServer.interface + +[GServer.interface] +install=$(PREFIX)/etc/AppInterface diff --git a/project.conf b/project.conf index 5b00d0f..1aaf25b 100644 --- a/project.conf +++ b/project.conf @@ -1,5 +1,6 @@ package=GServer version=0.0.0 +config=h -subdirs=src -dist=COPYING,Makefile,TODO +subdirs=data,src +dist=COPYING,Makefile,TODO,config.h diff --git a/src/Makefile b/src/Makefile index 441d257..9b3ee72 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,14 +1,14 @@ SUBDIRS = video -TARGETS = GServer +TARGETS = ../data/GServer.h GServer PREFIX = /usr/local DESTDIR = BINDIR = $(PREFIX)/bin CC = cc -CPPFLAGSF= -I $(PREFIX)/include -CPPFLAGS= -CFLAGSF = -W `pkg-config --cflags glu` +CPPFLAGSF= +CPPFLAGS= -I $(PREFIX)/include +CFLAGSF = -W `pkg-config --cflags gl` CFLAGS = -Wall -g -O2 -pedantic -LDFLAGSF= -lSystem `pkg-config --libs glu` +LDFLAGSF= -lSystem `pkg-config --libs glu` -Wl,-export-dynamic LDFLAGS = -L$(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib RM = rm -f LN = ln -f @@ -21,6 +21,9 @@ all: subdirs $(TARGETS) subdirs: @for i in $(SUBDIRS); do (cd $$i && $(MAKE)) || exit; done +../data/GServer.h: ../data/GServer.interface + ./appbroker.sh "../data/GServer.h" + GServer_OBJS = gserver.o main.o GServer_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) GServer_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) @@ -28,7 +31,7 @@ GServer_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) GServer: $(GServer_OBJS) $(CC) -o GServer $(GServer_OBJS) $(GServer_LDFLAGS) -gserver.o: gserver.c gserver.h +gserver.o: gserver.c gserver.h ../data/GServer.h ../config.h $(CC) $(GServer_CFLAGS) -c gserver.c main.o: main.c gserver.h @@ -36,11 +39,11 @@ main.o: main.c gserver.h clean: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done - $(RM) -- $(GServer_OBJS) + $(RM) -- $(../data/GServer.h_OBJS) $(GServer_OBJS) distclean: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done - $(RM) -- $(GServer_OBJS) + $(RM) -- $(../data/GServer.h_OBJS) $(GServer_OBJS) $(RM) -- $(TARGETS) install: all diff --git a/src/appbroker.sh b/src/appbroker.sh new file mode 100755 index 0000000..fc375f4 --- /dev/null +++ b/src/appbroker.sh @@ -0,0 +1,20 @@ +#!/bin/sh +#$Id$ + + + +#usage +usage() +{ + echo "Usage: ./appbroker.sh target" 1>&2 + return 1 +} + + +#main +if [ $# -ne 1 ]; then + usage + exit $? +fi +APPINTERFACE="${1%%.h}.interface" +AppBroker -o "$1" "$APPINTERFACE" diff --git a/src/gserver.c b/src/gserver.c index 7854801..e572afb 100644 --- a/src/gserver.c +++ b/src/gserver.c @@ -1,14 +1,34 @@ /* $Id$ */ /* Copyright (c) 2010 Pierre Pronchery */ /* This file is part of DeforaOS Graphics GServer */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ #include #include #include +#include #include "video/video.h" +#include "../data/GServer.h" #include "gserver.h" +#include "../config.h" + +#ifdef DEBUG +# define DEBUG_INTERFACE() fprintf(stderr, "DEBUG: %s()\n", __func__) +#else +# define DEBUG_INTERFACE() +#endif /* GServer */ @@ -20,9 +40,17 @@ struct _GServer int event_own; AppServer * appserver; int loop; + + /* video */ + void * video_handle; + VideoPlugin * video_plugin; }; +/* variables */ +static GServer * _gserver = NULL; + + /* public */ /* functions */ /* gserver_new */ @@ -36,6 +64,7 @@ GServer * gserver_new(AppServerOptions options, Event * event) if((gserver = object_new(sizeof(*gserver))) == NULL) return NULL; + _gserver = gserver; if(_new_init(options, gserver, event) != 0) { object_delete(gserver); @@ -46,6 +75,8 @@ GServer * gserver_new(AppServerOptions options, Event * event) static int _new_init(AppServerOptions options, GServer * gserver, Event * event) { + gserver->video_handle = NULL; + gserver->video_plugin = NULL; if((gserver->event = event) != NULL) gserver->event_own = 0; else if((gserver->event = event_new()) == NULL) @@ -67,30 +98,32 @@ static int _new_init(AppServerOptions options, GServer * gserver, Event * event) } static int _init_video(GServer * gserver) - /* FIXME ask Hardware what to load instead of hard-coding vesa */ + /* FIXME ask Hardware what to load instead of hard-coding glx */ { - void * handle; - VideoPlugin * video; + char const filename[] = PREFIX "/lib/" PACKAGE "/video/glx.so"; - if((handle = dlopen("video/vesa.so", RTLD_LAZY)) == NULL) + if((gserver->video_handle = dlopen(filename, RTLD_LAZY)) == NULL) + return error_set_code(1, "%s: %s", filename, dlerror()); + if((gserver->video_plugin = dlsym(gserver->video_handle, + "video_plugin")) == NULL) { - fprintf(stderr, "%s%s%s", "GServer: vesa: ", dlerror(), "\n"); + error_set_code(1, "%s: %s", filename, dlerror()); + dlclose(gserver->video_handle); return 1; } - if((video = dlsym(handle, "video_plugin")) == NULL) - { - fprintf(stderr, "%s%s%s", "GServer: vesa: ", dlerror(), "\n"); - dlclose(handle); - return 1; - } - video->init(); + gserver->video_plugin->init(); return 0; } /* gserver_delete */ +static void _destroy_video(GServer * gserver); + void gserver_delete(GServer * gserver) { + if(_gserver == gserver) + _gserver = NULL; + _destroy_video(gserver); if(gserver->appserver != NULL) appserver_delete(gserver->appserver); if(gserver->event != NULL) @@ -98,6 +131,14 @@ void gserver_delete(GServer * gserver) object_delete(gserver); } +static void _destroy_video(GServer * gserver) +{ + if(gserver->video_plugin != NULL) + gserver->video_plugin->destroy(); + if(gserver->video_handle != NULL) + dlclose(gserver->video_handle); +} + /* useful */ int gserver_loop(GServer * gserver) @@ -108,3 +149,110 @@ int gserver_loop(GServer * gserver) ret |= event_loop(gserver->event); return ret; } + + +/* interface */ +/* GServer_glBegin */ +void GServer_glBegin(uint32_t mode) +{ + DEBUG_INTERFACE(); + glBegin(mode); +} + + +/* GServer_glClear */ +void GServer_glClear(uint32_t mask) +{ + DEBUG_INTERFACE(); + glClear(mask); +} + + +/* GServer_glClearColor */ +void GServer_glClearColor(float red, float green, float blue, float alpha) +{ + DEBUG_INTERFACE(); + glClearColor(red, green, blue, alpha); +} + + +/* GServer_glClearDepth */ +void GServer_glClearDepth(double depth) +{ + DEBUG_INTERFACE(); + glClearDepth(depth); +} + + +/* GServer_glColor3f */ +void GServer_glColor3f(float red, float green, float blue) +{ + DEBUG_INTERFACE(); + glColor3f(red, green, blue); +} + + +/* GServer_glColor3i */ +void GServer_glColor3i(int32_t red, int32_t green, int32_t blue) +{ + DEBUG_INTERFACE(); + glColor3i(red, green, blue); +} + + +/* GServer_glEnd */ +void GServer_glEnd(void) +{ + DEBUG_INTERFACE(); + glEnd(); +} + + +/* GServer_glFlush */ +void GServer_glFlush(void) +{ + DEBUG_INTERFACE(); + glFlush(); +} + + +/* GServer_glLoadIdentity */ +void GServer_glLoadIdentity(void) +{ + DEBUG_INTERFACE(); + glLoadIdentity(); +} + + +/* GServer_glTranslatef */ +void GServer_glTranslatef(float x, float y, float z) +{ + DEBUG_INTERFACE(); + glTranslatef(x, y, z); +} + + +/* GServer_glVertex3i */ +void GServer_glVertex3i(int32_t x, int32_t y, int32_t z) +{ + DEBUG_INTERFACE(); + glVertex3i(x, y, z); +} + + +/* GServer_glVertex3f */ +void GServer_glVertex3f(float x, float y, float z) +{ + DEBUG_INTERFACE(); + glVertex3f(x, y, z); +} + + +/* GServer_SwapBuffers */ +void GServer_SwapBuffers(void) +{ + DEBUG_INTERFACE(); + if(_gserver != NULL && _gserver->video_plugin != NULL + && _gserver->video_plugin->swap_buffers != NULL) + _gserver->video_plugin->swap_buffers(); +} diff --git a/src/gserver.h b/src/gserver.h index 62167e9..8f0a74f 100644 --- a/src/gserver.h +++ b/src/gserver.h @@ -1,6 +1,17 @@ /* $Id$ */ /* Copyright (c) 2010 Pierre Pronchery */ /* This file is part of DeforaOS Graphics GServer */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ diff --git a/src/main.c b/src/main.c index 05afaca..8b90a1d 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,17 @@ /* $Id$ */ /* Copyright (c) 2010 Pierre Pronchery */ /* This file is part of DeforaOS Graphics GServer */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ diff --git a/src/project.conf b/src/project.conf index c865318..9f7e8b1 100644 --- a/src/project.conf +++ b/src/project.conf @@ -1,18 +1,23 @@ subdirs=video -targets=GServer -cppflags_force=-I $(PREFIX)/include -cflags_force=-W `pkg-config --cflags glu` +targets=../data/GServer.h,GServer +cppflags=-I $(PREFIX)/include +cflags_force=-W `pkg-config --cflags gl` cflags=-Wall -g -O2 -pedantic -ldflags_force=-lSystem `pkg-config --libs glu` +ldflags_force=-lSystem `pkg-config --libs glu` -Wl,-export-dynamic ldflags=-L$(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib dist=Makefile,gserver.h +[../data/GServer.h] +type=script +script=./appbroker.sh +depends=../data/GServer.interface + [GServer] type=binary sources=gserver.c,main.c [gserver.c] -depends=gserver.h +depends=gserver.h,../data/GServer.h,../config.h [main.c] depends=gserver.h diff --git a/src/video/Makefile b/src/video/Makefile index fa23bf6..78bde2e 100644 --- a/src/video/Makefile +++ b/src/video/Makefile @@ -1,4 +1,4 @@ -TARGETS = vesa.a vesa.so +TARGETS = glx.so vesa.so PREFIX = /usr/local DESTDIR = LIBDIR = $(PREFIX)/lib @@ -18,31 +18,43 @@ INSTALL = install all: $(TARGETS) +glx_OBJS = glx.o +glx_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +glx_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +glx.so: $(glx_OBJS) + $(LD) -o glx.so $(glx_OBJS) + vesa_OBJS = vbe.o vesa.o vesa_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) vesa_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -vesa.a: $(vesa_OBJS) - $(AR) vesa.a $(vesa_OBJS) - $(RANLIB) vesa.a - vesa.so: $(vesa_OBJS) - $(LD) -o vesa.so -Wl,-soname,vesa.so.0 $(vesa_OBJS) + $(LD) -o vesa.so $(vesa_OBJS) + +glx.o: glx.c video.h + $(CC) $(glx_CFLAGS) `pkg-config --cflags gl` -c glx.c vbe.o: vbe.c $(CC) $(vesa_CFLAGS) -c vbe.c -vesa.o: vesa.c +vesa.o: vesa.c video.h $(CC) $(vesa_CFLAGS) -c vesa.c clean: - $(RM) -- $(vesa_OBJS) + $(RM) -- $(glx_OBJS) $(vesa_OBJS) distclean: clean $(RM) -- $(TARGETS) install: all + $(MKDIR) $(DESTDIR)$(PREFIX)/lib/GServer/video + $(INSTALL) -m 0644 -- glx.so $(DESTDIR)$(PREFIX)/lib/GServer/video/glx.so + $(MKDIR) $(DESTDIR)$(PREFIX)/lib/GServer/video + $(INSTALL) -m 0644 -- vesa.so $(DESTDIR)$(PREFIX)/lib/GServer/video/vesa.so uninstall: + $(RM) -- $(DESTDIR)$(PREFIX)/lib/GServer/video/glx.so + $(RM) -- $(DESTDIR)$(PREFIX)/lib/GServer/video/vesa.so .PHONY: all clean distclean install uninstall diff --git a/src/video/glx.c b/src/video/glx.c new file mode 100644 index 0000000..e4b8dd1 --- /dev/null +++ b/src/video/glx.c @@ -0,0 +1,162 @@ +/* $Id$ */ +/* Copyright (c) 2010 Pierre Pronchery */ +/* This file is part of DeforaOS Graphics GServer */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#ifdef DEBUG +# include +#endif +#include +#include +#include +#include "video.h" + + +/* GLX */ +/* private */ +/* prototypes */ +static int _glx_init(void); +static void _glx_destroy(void); +static void _glx_swap_buffers(void); + + +/* variables */ +static Display * _display; +static Window _window; + + +/* public */ +/* variables */ +VideoPlugin video_plugin = +{ + _glx_init, + _glx_destroy, + _glx_swap_buffers +}; + + +/* private */ +/* functions */ +/* glx_init */ +static int _glx_init(void) +{ + int screen; + int attributes[] = { GLX_RGBA, GLX_RED_SIZE, 4, GLX_GREEN_SIZE, 4, + GLX_BLUE_SIZE, 4, GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None }; + XVisualInfo * vi; + GLXContext context; + XSetWindowAttributes attr; + Atom wdelete; + int x; + int y; + unsigned int width; + unsigned int height; + unsigned int depth; + Window wdummy; + unsigned int bdummy; + +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s()\n", __func__); +#endif + _display = XOpenDisplay(0); + screen = DefaultScreen(_display); +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s() screen=%d\n", __func__, screen); +#endif + if((vi = glXChooseVisual(_display, screen, attributes)) == NULL) + { + attributes[(sizeof(attributes) / sizeof(*attributes)) - 2] + = None; + vi = glXChooseVisual(_display, screen, attributes); + } +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s() got visual\n", __func__); +#endif + context = glXCreateContext(_display, vi, 0, GL_TRUE); + memset(&attr, 0, sizeof(attr)); + attr.colormap = XCreateColormap(_display, RootWindow(_display, + vi->screen), vi->visual, AllocNone); + attr.border_pixel = 0; + attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask + | StructureNotifyMask; + _window = XCreateWindow(_display, RootWindow(_display, vi->screen), + 0, 0, 640, 480, 0, vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask, &attr); + wdelete = XInternAtom(_display, "WM_DELETE_WINDOW", True); + XSetWMProtocols(_display, _window, &wdelete, 1); + XSetStandardProperties(_display, _window, "GServer GLX", "GServer GLX", + None, NULL, 0, NULL); + XMapRaised(_display, _window); + glXMakeCurrent(_display, _window, context); + XGetGeometry(_display, _window, &wdummy, &x, &y, &width, &height, + &bdummy, &depth); +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s() (%d,%d) (%ux%u@%u)\n", __func__, x, y, + width, height, depth); +#endif + glShadeModel(GL_SMOOTH); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearDepth(1.0f); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + if(height == 0) + height = 1; + gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glFlush(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glXSwapBuffers(_display, _window); + return 0; +} + + +/* glx_destroy */ +static void _glx_destroy(void) +{ +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s()\n", __func__); +#endif +} + + +/* glx_swap_buffers */ +static void _glx_swap_buffers(void) +{ +#if 0 + XEvent event; + + while(XPending(_display) > 0) + { + XNextEvent(_display, &event); + } +#endif + glViewport(0, 0, 640, 480); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(45.0f, (GLfloat)640 / (GLfloat)480, 0.1f, 100.0f); + glMatrixMode(GL_MODELVIEW); + glTranslatef(3.0f, 0.0f, 0.0f); + glBegin(GL_QUADS); + glVertex3f(-1.0f, 1.0f, 0.0f); + glVertex3f(1.0f, 1.0f, 0.0f); + glVertex3f(1.0f, -1.0f, 0.0f); + glVertex3f(-1.0f, -1.0f, 0.0f); + glEnd(); + glXSwapBuffers(_display, _window); +} diff --git a/src/video/project.conf b/src/video/project.conf index 41377b1..e39f6f6 100644 --- a/src/video/project.conf +++ b/src/video/project.conf @@ -1,8 +1,21 @@ -targets=vesa +targets=glx,vesa cflags_force=-W cflags=-Wall -g -O2 -fPIC -pedantic dist=Makefile,vbe.h,video.h +[glx] +type=plugin +sources=glx.c +install=$(PREFIX)/lib/GServer/video + +[glx.c] +cflags=`pkg-config --cflags gl` +depends=video.h + [vesa] -type=library +type=plugin sources=vbe.c,vesa.c +install=$(PREFIX)/lib/GServer/video + +[vesa.c] +depends=video.h diff --git a/src/video/vbe.h b/src/video/vbe.h index e5e1f53..bf32ac5 100644 --- a/src/video/vbe.h +++ b/src/video/vbe.h @@ -1,9 +1,22 @@ -/* video/vbe.h */ +/* $Id$ */ +/* Copyright (c) 2010 Pierre Pronchery */ +/* This file is part of DeforaOS Graphics GServer */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef __VIDEO_VBE_H -# define __VIDEO_VBE_H +#ifndef GSERVER_VIDEO_VBE_H +# define GSERVER_VIDEO_VBE_H #include @@ -31,4 +44,4 @@ typedef struct _VbeInfo /* functions */ int vbe_info(VbeInfo * buf); -#endif /* !__VIDEO_VBE_H */ +#endif /* !GSERVER_VIDEO_VBE_H */ diff --git a/src/video/vesa.c b/src/video/vesa.c index c73dab0..c9f37c0 100644 --- a/src/video/vesa.c +++ b/src/video/vesa.c @@ -1,25 +1,45 @@ -/* video/vesa.c */ +/* $Id$ */ +/* Copyright (c) 2010 Pierre Pronchery */ +/* This file is part of DeforaOS Graphics GServer */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ +#include #include "video.h" #include "vbe.h" +/* private */ /* functions */ -int vesa_init(void) +/* vesa_init */ +static int _vesa_init(void) { return 0; } -void vesa_destroy() +/* vesa_destroy */ +static void _vesa_destroy(void) { } +/* public */ +/* variables */ VideoPlugin video_plugin = { - vesa_init, - vesa_destroy + _vesa_init, + _vesa_destroy, + NULL }; diff --git a/src/video/video.h b/src/video/video.h index 6c4b45a..97531be 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -1,17 +1,31 @@ -/* video/video.h */ +/* $Id$ */ +/* Copyright (c) 2010 Pierre Pronchery */ +/* This file is part of DeforaOS Graphics GServer */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef __VIDEO_VIDEO_H -# define __VIDEO_VIDEO_H +#ifndef GSERVER_VIDEO_VIDEO_H +# define GSERVER_VIDEO_VIDEO_H /* Video */ /* types */ typedef struct _VideoPlugin { - int (* init)(void); - void (* destroy)(void); + int (*init)(void); + void (*destroy)(void); + void (*swap_buffers)(void); } VideoPlugin; -#endif /* !__VIDEO_VIDEO_H */ +#endif /* !GSERVER_VIDEO_VIDEO_H */