Author: spitzak
Date: 2007-06-06 13:48:47 -0400 (Wed, 06 Jun 2007)
New Revision: 5880
Log:
Added option to compile to use glew (the OpenGL Extension Wrangler library).
This makes it much easier to call modern OpenGL extensions by name.
The ability to turn this on is not yet in configure.in.
Modified:
trunk/OpenGL/Fl_Gl_Window.cxx
trunk/OpenGL/GlChoice.h
trunk/OpenGL/gl_draw.cxx
trunk/configh.in
trunk/fltk/gl.h
Modified: trunk/OpenGL/Fl_Gl_Window.cxx
===================================================================
--- trunk/OpenGL/Fl_Gl_Window.cxx 2007-06-06 17:46:35 UTC (rev 5879)
+++ trunk/OpenGL/Fl_Gl_Window.cxx 2007-06-06 17:48:47 UTC (rev 5880)
@@ -248,12 +248,19 @@
if (!gl_choice) {error("Insufficient GL support"); return;}
}
#endif
+
if (!context_) {
mode_ &= ~NON_LOCAL_CONTEXT;
context_ = create_gl_context(this, gl_choice);
+ set_gl_context(this, context_);
+#if USE_GLEW
+ glewExperimental = GL_TRUE;
+ glewInit();
+#endif
valid(0);
+ } else {
+ set_gl_context(this, context_);
}
- set_gl_context(this, context_);
}
/**
@@ -363,8 +370,8 @@
static GLContext ortho_context = 0;
static GlWindow* ortho_window = 0;
if (!ortho_context) {
- ortho_context = create_gl_context(this, gl_choice);
- save_valid = 0;
+ ortho_context = create_gl_context(this, gl_choice);
+ save_valid = 0;
}
set_gl_context(this, ortho_context);
if (!save_valid || ortho_window != this) {
Modified: trunk/OpenGL/GlChoice.h
===================================================================
--- trunk/OpenGL/GlChoice.h 2007-06-06 17:46:35 UTC (rev 5879)
+++ trunk/OpenGL/GlChoice.h 2007-06-06 17:48:47 UTC (rev 5880)
@@ -70,7 +70,11 @@
#else
# include <fltk/x.h>
# define Window XWindow
-# include <GL/glx.h>
+# if USE_GLEW
+# include <GL/glxew.h>
+# else
+# include <GL/glx.h>
+# endif
# undef Window
# define GLContext GLXContext
#endif
Modified: trunk/OpenGL/gl_draw.cxx
===================================================================
--- trunk/OpenGL/gl_draw.cxx 2007-06-06 17:46:35 UTC (rev 5879)
+++ trunk/OpenGL/gl_draw.cxx 2007-06-06 17:48:47 UTC (rev 5880)
@@ -302,24 +302,6 @@
glDrawPixels(w, h, d<4?GL_RGB:GL_RGBA, GL_UNSIGNED_BYTE, (const unsigned
long*)b);
}
-#ifndef GL_VERSION_1_4
-/*!
- Emulate glWindowPos2i on Windows. This emulation is extremely simple
- and only produces the correct result if ortho() has been called (i.e.
- the current transform is such that 0,0 is the lower-left of the
- window and each unit is the size of a pixel). This function is \e not
- in the fltk:: namespace.
-*/
-void glWindowPos2i(int x, int y) {
- if (x < 0 || y < 0) {
- glRasterPos2i(0,0);
- glBitmap(0,0,0,0,(GLfloat)x,(GLfloat)y,0);
- } else {
- glRasterPos2i(x,y);
- }
-}
-#endif
-
const char* fl_default_font_pathname;
#if USE_XFT
Modified: trunk/configh.in
===================================================================
--- trunk/configh.in 2007-06-06 17:46:35 UTC (rev 5879)
+++ trunk/configh.in 2007-06-06 17:48:47 UTC (rev 5880)
@@ -162,6 +162,13 @@
and visual management code. */
#define USE_GL_OVERLAY 0
+/* Use the Open GL Extension Wrangler library. This does a far better
+ job than fltk/gl.h at fixing OpenGL on windows and allows you
+ to call any OpenGL extension and have the program run without
+ missing symbols (though you need to check if the extension
+ exists before you call it). See http://glew.sourceforge.net */
+#define USE_GLEW 0
+
/* Standard autoconf stuff to figure out readdir() header files.
(ignored for _WIN32) */
#undef HAVE_DIRENT_H
Modified: trunk/fltk/gl.h
===================================================================
--- trunk/fltk/gl.h 2007-06-06 17:46:35 UTC (rev 5879)
+++ trunk/fltk/gl.h 2007-06-06 17:48:47 UTC (rev 5880)
@@ -27,7 +27,10 @@
/*! \file
Portably include the OpenGL header files, and define a few OpenGL
- drawing functions provided by fltk.
+ drawing functions provided by fltk. You may want to use the
+ OpenGL Extension Wrangler (glew), which will make it much easier
+ to call modern OpenGL extensions. If so, include glew.h before
+ this file, or define USE_GLEW to 1 before including this.
*/
#ifndef gl_draw_H
@@ -37,34 +40,41 @@
#include "Color.h"
#include "Flags.h"
-#define GL_GLEXT_PROTOTYPES 1
-#ifdef _WIN32
-# include <windows.h>
-# undef OPAQUE
-# undef DELETE
-# undef ERROR
-# undef IN
-# undef OUT
-# undef POINT
-# undef far
-# undef max
-# undef min
-# undef near
-# include <GL/gl.h>
-#elif defined(__APPLE__)
+#if USE_GLEW
+# include <GL/glew.h>
+#elif defined(__GLEW_H__)
+ /* do nothing if they included glew.h */
+#else
+
+# define GL_GLEXT_PROTOTYPES 1
+# ifdef _WIN32
+# include <windows.h>
+# undef OPAQUE
+# undef DELETE
+# undef ERROR
+# undef IN
+# undef OUT
+# undef POINT
+# undef far
+# undef max
+# undef min
+# undef near
+# include <GL/gl.h>
+# elif defined(__APPLE__)
# ifndef APIENTRY
-# define APIENTRY
+# define APIENTRY
# endif
-# include <OpenGL/gl.h>
-#else
-# include <GL/gl.h>
-#endif
+# include <OpenGL/gl.h>
+# else
+# include <GL/gl.h>
+# endif
-#if !defined(GL_VERSION_1_4) || defined(DOXYGEN)
+# if !defined(GL_VERSION_1_4) || defined(DOXYGEN)
FL_GL_API void glWindowPos2i(int x, int y);
-#endif
+# endif
#endif
+#endif
namespace fltk {
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit