From 5832df65ce103312db50d1df460735f0afada36d Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 3 Mar 2004 01:29:08 +0000 Subject: [PATCH] compile on Linux --- panda/src/doc/eggSyntax.txt | 40 ++++++++++++++++++- .../glstuff/glGraphicsStateGuardian_src.cxx | 9 +++-- .../src/glstuff/glGraphicsStateGuardian_src.h | 2 +- panda/src/glstuff/glext.h | 9 ++++- panda/src/glxdisplay/glxGraphicsWindow.cxx | 34 +++++++++++++--- panda/src/glxdisplay/glxGraphicsWindow.h | 1 + 6 files changed, 81 insertions(+), 14 deletions(-) diff --git a/panda/src/doc/eggSyntax.txt b/panda/src/doc/eggSyntax.txt index bb2aa23654..1fba245f9b 100644 --- a/panda/src/doc/eggSyntax.txt +++ b/panda/src/doc/eggSyntax.txt @@ -227,7 +227,45 @@ appear before they are referenced. This defines a set of material attributes that may later be referenced with { name }. - At present, no material attributes have been implemented. + The following attributes may appear within the material block: + + diffr { number } + diffg { number } + diffb { number } + diffa { number } + + ambr { number } + ambg { number } + ambb { number } + amba { number } + + emitr { number } + emitg { number } + emitb { number } + emita { number } + + specr { number } + specg { number } + specb { number } + speca { number } + + shininess { number } + local { flag } + + These properties collectively define a "material" that controls the + lighting effects that are applied to a surface; a material is only + in effect in the presence of lighting. + + The four color groups, diff*, amb*, emit*, and spec* specify the + diffuse, ambient, emission, and specular components of the lighting + equation, respectively. Any of them may be omitted; the omitted + component(s) take their color from the native color of the + primitive, otherwise the primitive color is replaced with the + material color. + + The shininess property controls the size of the specular highlight, + and the value ranges from 0 to 128. A larger value creates a + smaller highlight (creating the appearance of a shinier surface). name { vertices } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 26a078e8f2..9f8e277fef 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -2783,14 +2783,15 @@ has_extension(const string &extension) const { // least the indicated value, false otherwise. //////////////////////////////////////////////////////////////////// bool CLP(GraphicsStateGuardian):: -is_at_least_version(int major, int minor, int release) const { - if (_gl_version_major < major) { +is_at_least_version(int major_version, int minor_version, + int release_version) const { + if (_gl_version_major < major_version) { return false; } - if (_gl_version_minor < minor) { + if (_gl_version_minor < minor_version) { return false; } - if (_gl_version_release < release) { + if (_gl_version_release < release_version) { return false; } return true; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index b4462a750b..85a51ce0df 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -138,7 +138,7 @@ protected: virtual void get_extra_extensions(); void report_extensions() const; bool has_extension(const string &extension) const; - bool is_at_least_version(int major, int minor, int release = 0) const; + bool is_at_least_version(int major_version, int minor_version, int release_version = 0) const; virtual bool slot_new_light(int light_id); virtual void enable_lighting(bool enable); diff --git a/panda/src/glstuff/glext.h b/panda/src/glstuff/glext.h index 56d7399426..79c93099a5 100644 --- a/panda/src/glstuff/glext.h +++ b/panda/src/glstuff/glext.h @@ -1,5 +1,10 @@ -#ifndef __glext_h_ -#define __glext_h_ +/* Additions by drose to re-include this glext.h even if an older + version has previously been included. */ +#if defined(GL_GLEXT_VERSION) && GL_GLEXT_VERSION < 21 + #undef GL_GLEXT_VERSION +#endif +#ifndef GL_GLEXT_VERSION + #ifdef __cplusplus extern "C" { diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index 1f63ae9190..9b99722af8 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -68,6 +68,34 @@ glxGraphicsWindow:: ~glxGraphicsWindow() { } +//////////////////////////////////////////////////////////////////// +// Function: glxGraphicsWindow::make_context +// Access: Public, Virtual +// Description: If _needs_context is true, this will be called +// in the draw thread prior to rendering into the +// window. It should attempt to create a graphics +// context, and return true if successful, false +// otherwise. If it returns false the window will be +// considered failed. +//////////////////////////////////////////////////////////////////// +bool glxGraphicsWindow:: +make_context() { + PStatTimer timer(_make_current_pcollector); + + glxGraphicsStateGuardian *glxgsg; + DCAST_INTO_R(glxgsg, _gsg, false); + glXMakeCurrent(_display, _xwindow, glxgsg->_context); + _needs_context = false; + + // Now that we have made the context current to a window, we can + // reset the GSG state if this is the first time it has been used. + // (We can't just call reset() when we construct the GSG, because + // reset() requires having a current context.) + glxgsg->reset_if_new(); + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: glxGraphicsWindow::make_current // Access: Public, Virtual @@ -82,12 +110,6 @@ make_current() { glxGraphicsStateGuardian *glxgsg; DCAST_INTO_V(glxgsg, _gsg); glXMakeCurrent(_display, _xwindow, glxgsg->_context); - - // Now that we have made the context current to a window, we can - // reset the GSG state if this is the first time it has been used. - // (We can't just call reset() when we construct the GSG, because - // reset() requires having a current context.) - glxgsg->reset_if_new(); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/glxdisplay/glxGraphicsWindow.h b/panda/src/glxdisplay/glxGraphicsWindow.h index 92a83e4316..2dd473f074 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.h +++ b/panda/src/glxdisplay/glxGraphicsWindow.h @@ -36,6 +36,7 @@ public: const string &name); virtual ~glxGraphicsWindow(); + virtual bool make_context(); virtual void make_current(); virtual void release_gsg();