From Paul Martz, changes for compiling against OpenGL 3.x

This commit is contained in:
Robert Osfield 2009-11-03 16:34:54 +00:00
parent 8d67c9bb33
commit 72ff1f40f9
22 changed files with 87 additions and 32 deletions

View File

@ -723,7 +723,7 @@ int main( int argc, char **argv )
}
#if !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
// add back in enabling of the GL_ALPHA_TEST to get around the core OSG no longer setting it by default for opaque bins.
// the alpha test is required for the volume rendering alpha clipping to work.

View File

@ -31,6 +31,11 @@
#define GL_CLAMP_FRAGMENT_COLOR GL_CLAMP_FRAGMENT_COLOR_ARB
#endif
#if defined(OSG_GL3_AVAILABLE)
#define GL_CLAMP_VERTEX_COLOR 0x891A
#define GL_CLAMP_FRAGMENT_COLOR 0x891B
#endif
namespace osg {
/** Encapsulates OpenGL ClampColor state. */

View File

@ -87,6 +87,11 @@
#include <GLES2/gl2.h>
#elif defined(OSG_GL3_AVAILABLE)
#define GL3_PROTOTYPES 1
#include <GL3/gl3.h>
#else
#ifndef __gl_h_
@ -145,12 +150,17 @@
#define GL_NONE 0x0
#endif
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE)
#define GL_POLYGON 0x0009
#define GL_QUADS 0x0007
#define GL_QUAD_STRIP 0x0008
#endif
#if defined(OSG_GL3_AVAILABLE)
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
#endif
#ifdef OSG_GLES1_AVAILABLE
inline void glColor4ubv(const GLubyte* c) { glColor4ub(c[0], c[1], c[2], c[3]); }
inline void glColor3fv(const GLfloat* c) { glColor4f(c[0], c[1], c[2], 1.0f); }

View File

@ -17,7 +17,7 @@
#include <osg/Plane>
#include <osg/StateAttribute>
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE)
#define GL_OBJECT_LINEAR 0x2401
#define GL_EYE_LINEAR 0x2400
#define GL_SPHERE_MAP 0x2402

View File

@ -32,12 +32,16 @@
#include "dxtctool.h"
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
#define GL_BITMAP 0x1A00
#define GL_RED 0x1903
#define GL_GREEN 0x1904
#define GL_BLUE 0x1905
#define GL_COLOR_INDEX 0x1900
#define GL_DEPTH_COMPONENT 0x1902
#define GL_STENCIL_INDEX 0x1901
#endif
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GL3_AVAILABLE)
#define GL_BITMAP 0x1A00
#define GL_COLOR_INDEX 0x1900
#define GL_INTENSITY12 0x804C
#define GL_INTENSITY16 0x804D
#define GL_INTENSITY4 0x804A
@ -52,7 +56,6 @@
#define GL_LUMINANCE6_ALPHA2 0x8044
#define GL_LUMINANCE8 0x8040
#define GL_LUMINANCE8_ALPHA8 0x8045
#define GL_STENCIL_INDEX 0x1901
#define GL_RGBA8 0x8058
#define GL_PACK_ROW_LENGTH 0x0D02
#endif

View File

@ -1747,7 +1747,7 @@ void Texture::applyTexImage2D_load(State& state, GLenum target, const Image* ima
{
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,GL_TRUE);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY,0.0f);
#endif

View File

@ -297,7 +297,7 @@ void TextureRectangle::applyTexImage_load(GLenum target, Image* image, State& st
{
glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE,GL_TRUE);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_PRIORITY,0.0f);
#endif

View File

@ -2007,7 +2007,7 @@ void DatabasePager::compileGLObjects(osg::State& state, double& availableTime)
if (!dtc.first.empty() && (elapsedTime+estimatedTextureDuration)<availableTime && numObjectsCompiled<_maximumNumOfObjectsToCompilePerFrame)
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_PRIORITY, 1.0);
#endif
@ -2031,7 +2031,7 @@ void DatabasePager::compileGLObjects(osg::State& state, double& availableTime)
(*itr)->compileGLObjects(state);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
GLint p;
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_RESIDENT, &p);
#endif

View File

@ -216,7 +216,7 @@ namespace
texenv->setMode(osg::TexEnv::DECAL);
ss->setTextureAttributeAndModes(0, texenv.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
#if !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
ss->setMode( GL_ALPHA_TEST, osg::StateAttribute::OFF );
#else
osg::notify(osg::NOTICE)<<"Warning: osgFX::AnisotropicLighting unable to disable GL_ALPHA_TEST."<<std::endl;

View File

@ -106,7 +106,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo
osg::Matrix modelview = state.getModelViewMatrix();
// set up depth mask for first rendering pass
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
glPushAttrib(GL_DEPTH_BUFFER_BIT);
#endif
@ -115,7 +115,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo
// render, first pass
single_pass_render(state, modelview);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
// restore depth mask settings
glPopAttrib();
#endif
@ -123,7 +123,7 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo
// render, second pass
if (_doublepass) {
// set up color mask for second rendering pass
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
glPushAttrib(GL_COLOR_BUFFER_BIT);
#endif
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
@ -131,13 +131,13 @@ void osgParticle::ParticleSystem::drawImplementation(osg::RenderInfo& renderInfo
// render the particles onto the depth buffer
single_pass_render(state, modelview);
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
// restore color mask settings
glPopAttrib();
#endif
}
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
osg::notify(osg::NOTICE)<<"Warning: ParticleSystem::drawImplementation(..) not fully implemented."<<std::endl;
#endif

View File

@ -41,6 +41,12 @@
#define GL_INTENSITY16 0x804D
#endif
#if defined(OSG_GL3_AVAILABLE)
#define GL_LUMINANCE12_ALPHA4 0x8046
#define GL_LUMINANCE12_ALPHA12 0x8047
#define GL_INTENSITY16 0x804D
#endif
namespace flt {
class VertexPalette : public Record

View File

@ -40,6 +40,10 @@
#define GL_LUMINANCE4_ALPHA4 0x8043
#endif
#if defined(OSG_GL3_AVAILABLE)
#define GL_LUMINANCE4_ALPHA4 0x8043
#endif
// NOTICE ON WIN32:
// typedef DWORD unsigned long;
// sizeof(DWORD) = 4

View File

@ -95,7 +95,7 @@ class Logos: public osg::Drawable
virtual void drawImplementation(osg::RenderInfo& renderInfo) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
if( renderInfo.getContextID() != _contextID )
return;

View File

@ -131,6 +131,10 @@ void initGLNames()
ADD_NAME("GL_LIGHT6",GL_LIGHT6);
ADD_NAME("GL_LIGHT7",GL_LIGHT7);
#if defined(OSG_GL3_AVAILABLE)
#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
#endif
ADD_NAME("GL_VERTEX_PROGRAM_POINT_SIZE", GL_VERTEX_PROGRAM_POINT_SIZE)
ADD_NAME("GL_VERTEX_PROGRAM_TWO_SIDE", GL_VERTEX_PROGRAM_TWO_SIDE)

View File

@ -30,6 +30,11 @@
#define GL_COLOR_INDEX 0x1900
#endif
#if defined(OSG_GL3_AVAILABLE)
#define GL_BITMAP 0x1A00
#define GL_COLOR_INDEX 0x1900
#endif
using namespace osg;

View File

@ -84,7 +84,7 @@ void LightPointDrawable::reset()
void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
osg::State& state = *renderInfo.getState();
state.applyMode(GL_POINT_SMOOTH,true);

View File

@ -30,7 +30,7 @@ LightPointSpriteDrawable::LightPointSpriteDrawable(const LightPointSpriteDrawabl
void LightPointSpriteDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
osg::State& state = *renderInfo.getState();
if (!state.getModeValidity(GL_POINT_SPRITE_ARB))

View File

@ -1353,7 +1353,7 @@ void Text::drawImplementation(osg::State& state, const osg::Vec4& colorMultiplie
{
if (_textBB.valid())
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
state.applyTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OFF);
const osg::Matrix& matrix = _autoTransformCache[contextID]._matrix;
@ -1848,7 +1848,7 @@ void Text::renderOnlyForegroundText(osg::State& state, const osg::Vec4& colorMul
void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
unsigned int contextID = state.getContextID();
if (!osg::PolygonOffset::areFactorAndUnitsMultipliersSet())
@ -1913,7 +1913,7 @@ void Text::renderWithPolygonOffset(osg::State& state, const osg::Vec4& colorMult
void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
unsigned int contextID = state.getContextID();
glPushAttrib(GL_DEPTH_BUFFER_BIT);
@ -1967,7 +1967,7 @@ void Text::renderWithNoDepthBuffer(osg::State& state, const osg::Vec4& colorMult
// This idea comes from Paul Martz's OpenGL FAQ: 13.050
void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
unsigned int contextID = state.getContextID();
// Hmmm, the man page says GL_VIEWPORT_BIT for Depth range (near and far)
@ -2027,7 +2027,7 @@ void Text::renderWithDepthRange(osg::State& state, const osg::Vec4& colorMultipl
void Text::renderWithStencilBuffer(osg::State& state, const osg::Vec4& colorMultiplier) const
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
/* Here are the steps:
* 1) Disable drawing color
* 2) Enable the stencil buffer

View File

@ -527,7 +527,7 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
{
renderInfo.getState()->disableAllVertexArrays();
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
glPushAttrib(GL_TRANSFORM_BIT);
glEnable(GL_RESCALE_NORMAL);
#endif
@ -539,7 +539,7 @@ void Text3D::drawImplementation(osg::RenderInfo& renderInfo) const
default: renderPerGlyph(*renderInfo.getState()); break;
}
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
glPopAttrib();
#endif
}

View File

@ -1286,7 +1286,7 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
state.haveAppliedAttribute( osg::StateAttribute::STENCIL );
}
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
if (_clearMask & GL_ACCUM_BUFFER_BIT)
{
glClearAccum( _clearAccum[0], _clearAccum[1], _clearAccum[2], _clearAccum[3]);

View File

@ -30,7 +30,7 @@
using namespace osg;
using namespace osgUtil;
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
// define under GLES to keep the main SceneView.cpp clean.
#define GL_BACK_LEFT 0x0402
#define GL_BACK_RIGHT 0x0403
@ -1289,7 +1289,7 @@ void SceneView::draw()
break;
case(osg::DisplaySettings::VERTICAL_INTERLACE):
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
if( 0 == ( _camera->getInheritanceMask() & DRAW_BUFFER) )
{
_renderStageLeft->setDrawBuffer(_camera->getDrawBuffer());
@ -1372,7 +1372,7 @@ void SceneView::draw()
break;
case(osg::DisplaySettings::HORIZONTAL_INTERLACE):
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
if( 0 == ( _camera->getInheritanceMask() & DRAW_BUFFER) )
{
_renderStageLeft->setDrawBuffer(_camera->getDrawBuffer());
@ -1454,7 +1454,7 @@ void SceneView::draw()
break;
case(osg::DisplaySettings::CHECKERBOARD):
{
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE)
#if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) && !defined(OSG_GL3_AVAILABLE)
if( 0 == ( _camera->getInheritanceMask() & DRAW_BUFFER) )
{
_renderStageLeft->setDrawBuffer(_camera->getDrawBuffer());

View File

@ -92,6 +92,24 @@ static osg::ApplicationUsageProxy GraphicsWindowWin32_e0(osg::ApplicationUsage::
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#ifndef WGL_ARB_create_context
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define ERROR_INVALID_VERSION_ARB 0x2095
#endif
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HGLRC WINAPI wglCreateContextAttribsARB (HDC, HGLRC, const int *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
#endif
//
// Entry points used from the WGL extensions
//