diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-08-26 14:44:12 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-09-02 01:08:49 +0200 |
commit | 49a788a3779d78b37b116af6e2eba9a0eb7431e1 (patch) | |
tree | 8becf2aedb8359049c8ea82e3f9380352ba30bdb /slideshow | |
parent | 276b3d1f8ab2f67b403e312a94c9abe6ae7b792f (diff) |
add OpenGL error checking to OGLTrans
Change-Id: I9e511221e3da54b44935ebde22c49e5a151f6961
Diffstat (limited to 'slideshow')
-rw-r--r-- | slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx | 42 | ||||
-rw-r--r-- | slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx | 26 |
2 files changed, 68 insertions, 0 deletions
diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx index 222590c74fcb..6af10277e5ec 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionImpl.cxx @@ -99,6 +99,7 @@ void OGLTransitionImpl::finish() static void blendSlide( double depth ) { + CHECK_GL_ERROR(); double showHeight = -1 + depth*2; GLfloat reflectionColor[] = {0, 0, 0, 0.25}; @@ -121,10 +122,12 @@ static void blendSlide( double depth ) glVertex3f( 1, showHeight, 0 ); glEnd(); glEnable( GL_DEPTH_TEST ); + CHECK_GL_ERROR(); } static void slideShadow( double nTime, const Primitive& primitive, double sw, double sh ) { + CHECK_GL_ERROR(); double reflectionDepth = 0.3; glEnable(GL_BLEND); @@ -138,6 +141,7 @@ static void slideShadow( double nTime, const Primitive& primitive, double sw, do glDisable(GL_BLEND); glEnable(GL_LIGHTING); + CHECK_GL_ERROR(); } void OGLTransitionImpl::prepare_( double, double, double, double, double ) @@ -154,6 +158,7 @@ void OGLTransitionImpl::finishTransition_() void OGLTransitionImpl::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) { + CHECK_GL_ERROR(); applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale ); glEnable(GL_TEXTURE_2D); @@ -173,6 +178,7 @@ void OGLTransitionImpl::display( double nTime, ::sal_Int32 glLeavingSlideTex, :: displaySlides_( nTime, glLeavingSlideTex, glEnteringSlideTex, SlideWidthScale, SlideHeightScale ); displayScene( nTime, SlideWidth, SlideHeight, DispWidth, DispHeight ); glPopMatrix(); + CHECK_GL_ERROR(); } void OGLTransitionImpl::applyOverallOperations( double nTime, double SlideWidthScale, double SlideHeightScale ) @@ -188,6 +194,7 @@ OGLTransitionImpl::displaySlide( const ::sal_Int32 glSlideTex, const Primitives_t& primitives, double SlideWidthScale, double SlideHeightScale ) { + CHECK_GL_ERROR(); //TODO change to foreach glBindTexture(GL_TEXTURE_2D, glSlideTex); @@ -215,18 +222,22 @@ OGLTransitionImpl::displaySlide( for(unsigned int i(0); i < primitives.size(); ++i) primitives[i].display(nTime, SlideWidthScale, SlideHeightScale); + CHECK_GL_ERROR(); } void OGLTransitionImpl::displayScene( double nTime, double SlideWidth, double SlideHeight, double DispWidth, double DispHeight ) { + CHECK_GL_ERROR(); const SceneObjects_t& rSceneObjects(maScene.getSceneObjects()); glEnable(GL_TEXTURE_2D); for(unsigned int i(0); i != rSceneObjects.size(); ++i) rSceneObjects[i]->display(nTime, SlideWidth, SlideHeight, DispWidth, DispHeight); + CHECK_GL_ERROR(); } void Primitive::display(double nTime, double WidthScale, double HeightScale) const { + CHECK_GL_ERROR(); glPushMatrix(); applyOperations( nTime, WidthScale, HeightScale ); @@ -242,17 +253,21 @@ void Primitive::display(double nTime, double WidthScale, double HeightScale) con glVertexPointer( 3, GL_DOUBLE, 0, &Vertices[0] ); glDrawArrays( GL_TRIANGLES, 0, Vertices.size() ); glPopMatrix(); + CHECK_GL_ERROR(); } void Primitive::applyOperations(double nTime, double WidthScale, double HeightScale) const { + CHECK_GL_ERROR(); for(unsigned int i(0); i < Operations.size(); ++i) Operations[i]->interpolate( nTime ,WidthScale,HeightScale); glScaled(WidthScale,HeightScale,1); + CHECK_GL_ERROR(); } void SceneObject::display(double nTime, double /* SlideWidth */, double /* SlideHeight */, double DispWidth, double DispHeight ) const { + CHECK_GL_ERROR(); for(unsigned int i(0); i < maPrimitives.size(); ++i) { // fixme: allow various model spaces, now we make it so that // it is regular -1,-1 to 1,1, where the whole display fits in @@ -264,6 +279,7 @@ void SceneObject::display(double nTime, double /* SlideWidth */, double /* Slide maPrimitives[i].display(nTime, 1, 1); glPopMatrix(); } + CHECK_GL_ERROR(); } void SceneObject::pushPrimitive(const Primitive &p) @@ -294,6 +310,7 @@ void Iris::display(double nTime, double SlideWidth, double SlideHeight, double D void Iris::prepare() { + CHECK_GL_ERROR(); static const GLubyte img[3] = { 80, 80, 80 }; glGenTextures(1, &maTexture); @@ -303,11 +320,14 @@ void Iris::prepare() glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + CHECK_GL_ERROR(); } void Iris::finish() { + CHECK_GL_ERROR(); glDeleteTextures(1, &maTexture); + CHECK_GL_ERROR(); } namespace @@ -911,16 +931,19 @@ inline double intervalInter(double t, double T0, double T1) void STranslate::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const { + CHECK_GL_ERROR(); if(t <= nT0) return; if(!bInterpolate || t > nT1) t = nT1; t = intervalInter(t,nT0,nT1); glTranslated(SlideWidthScale*t*vector.getX(),SlideHeightScale*t*vector.getY(),t*vector.getZ()); + CHECK_GL_ERROR(); } void SRotate::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const { + CHECK_GL_ERROR(); if(t <= nT0) return; if(!bInterpolate || t > nT1) @@ -931,10 +954,12 @@ void SRotate::interpolate(double t,double SlideWidthScale,double SlideHeightScal glRotated(t*angle,axis.getX(),axis.getY(),axis.getZ()); glScaled(1/SlideWidthScale,1/SlideHeightScale,1); glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-origin.getZ()); + CHECK_GL_ERROR(); } void SScale::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const { + CHECK_GL_ERROR(); if(t <= nT0) return; if(!bInterpolate || t > nT1) @@ -943,10 +968,12 @@ void SScale::interpolate(double t,double SlideWidthScale,double SlideHeightScale glTranslated(SlideWidthScale*origin.getX(),SlideHeightScale*origin.getY(),origin.getZ()); glScaled((1-t) + t*scale.getX(),(1-t) + t*scale.getY(),(1-t) + t*scale.getZ()); glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-origin.getZ()); + CHECK_GL_ERROR(); } void RotateAndScaleDepthByWidth::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const { + CHECK_GL_ERROR(); if(t <= nT0) return; if(!bInterpolate || t > nT1) @@ -955,10 +982,12 @@ void RotateAndScaleDepthByWidth::interpolate(double t,double SlideWidthScale,dou glTranslated(SlideWidthScale*origin.getX(),SlideHeightScale*origin.getY(),SlideWidthScale*origin.getZ()); glRotated(t*angle,axis.getX(),axis.getY(),axis.getZ()); glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-SlideWidthScale*origin.getZ()); + CHECK_GL_ERROR(); } void RotateAndScaleDepthByHeight::interpolate(double t,double SlideWidthScale,double SlideHeightScale) const { + CHECK_GL_ERROR(); if(t <= nT0) return; if(!bInterpolate || t > nT1) @@ -967,6 +996,7 @@ void RotateAndScaleDepthByHeight::interpolate(double t,double SlideWidthScale,do glTranslated(SlideWidthScale*origin.getX(),SlideHeightScale*origin.getY(),SlideHeightScale*origin.getZ()); glRotated(t*angle,axis.getX(),axis.getY(),axis.getZ()); glTranslated(-SlideWidthScale*origin.getX(),-SlideHeightScale*origin.getY(),-SlideHeightScale*origin.getZ()); + CHECK_GL_ERROR(); } SEllipseTranslate::SEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1) @@ -1184,6 +1214,7 @@ private: void FadeSmoothlyTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) { + CHECK_GL_ERROR(); applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale ); glDisable(GL_DEPTH_TEST); @@ -1201,6 +1232,7 @@ void FadeSmoothlyTransition::displaySlides_( double nTime, ::sal_Int32 glLeaving glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); + CHECK_GL_ERROR(); } shared_ptr<OGLTransitionImpl> @@ -1250,6 +1282,7 @@ private: void FadeThroughBlackTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) { + CHECK_GL_ERROR(); applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale ); glDisable(GL_DEPTH_TEST); @@ -1270,6 +1303,7 @@ void FadeThroughBlackTransition::displaySlides_( double nTime, ::sal_Int32 glLea glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); + CHECK_GL_ERROR(); } shared_ptr<OGLTransitionImpl> @@ -1335,6 +1369,7 @@ private: void ShaderTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideTex, ::sal_Int32 glEnteringSlideTex, double SlideWidthScale, double SlideHeightScale ) { + CHECK_GL_ERROR(); applyOverallOperations( nTime, SlideWidthScale, SlideHeightScale ); if( m_nProgramObject ) { @@ -1349,6 +1384,7 @@ void ShaderTransition::displaySlides_( double nTime, ::sal_Int32 glLeavingSlideT glActiveTexture( GL_TEXTURE0 ); displaySlide( nTime, glLeavingSlideTex, getScene().getLeavingSlide(), SlideWidthScale, SlideHeightScale ); + CHECK_GL_ERROR(); } void ShaderTransition::prepareTransition_( ::sal_Int32 /* glLeavingSlideTex */, ::sal_Int32 /* glEnteringSlideTex */ ) @@ -1360,6 +1396,7 @@ void ShaderTransition::prepareTransition_( ::sal_Int32 /* glLeavingSlideTex */, void ShaderTransition::finishTransition_() { + CHECK_GL_ERROR(); if( m_nProgramObject ) { glDeleteProgram( m_nProgramObject ); m_nProgramObject = 0; @@ -1369,6 +1406,7 @@ void ShaderTransition::finishTransition_() glDeleteTextures( 1, &m_nHelperTexture ); m_nHelperTexture = 0; } + CHECK_GL_ERROR(); } int permutation256 [256]= { @@ -1408,6 +1446,7 @@ int permutation256 [256]= { void initPermTexture(GLuint *texID) { + CHECK_GL_ERROR(); glGenTextures(1, texID); glBindTexture(GL_TEXTURE_2D, *texID); @@ -1426,10 +1465,12 @@ void initPermTexture(GLuint *texID) glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, permutation2D ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + CHECK_GL_ERROR(); } void ShaderTransition::impl_preparePermShader() { + CHECK_GL_ERROR(); if( m_nProgramObject ) { glUseProgram( m_nProgramObject ); @@ -1453,6 +1494,7 @@ void ShaderTransition::impl_preparePermShader() glUniform1i( location, 2 ); // texture unit 2 } } + CHECK_GL_ERROR(); } } diff --git a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx index 879024ee98a0..b7184820162b 100644 --- a/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx +++ b/slideshow/source/engine/OGLTrans/generic/OGLTrans_TransitionerImpl.cxx @@ -318,11 +318,13 @@ bool OGLTransitionerImpl::initialize( const Reference< presentation::XSlideShowV setSlides( xLeavingSlide, xEnteringSlide ); + CHECK_GL_ERROR(); return mbValidOpenGLContext; } void OGLTransitionerImpl::impl_initializeFlags( bool const bValidContext ) { + CHECK_GL_ERROR(); mbValidOpenGLContext = bValidContext; if ( bValidContext ) { mnGLVersion = OpenGLHelper::getGLVersion(); @@ -333,6 +335,7 @@ void OGLTransitionerImpl::impl_initializeFlags( bool const bValidContext ) /* TODO: check for version once the bug in fglrx driver is fixed */ mbBrokenTexturesATI = (vendor && strcmp( (const char *) vendor, "ATI Technologies Inc." ) == 0 ); } + CHECK_GL_ERROR(); } bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presentation::XSlideShowView >& xView ) @@ -361,12 +364,14 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta sal_Int64 aVal = 0; aDeviceParams[1] >>= aVal; + SAL_WARN("slideshow", "created the context"); mpContext = boost::make_shared<OpenGLContext>(); mpContext->requestLegacyContext(); if( !mpContext->init( reinterpret_cast< Window* >( aVal ) ) ) return false; + CHECK_GL_ERROR(); awt::Rectangle aCanvasArea = mxView->getCanvasArea(); mpContext->setWinPosAndSize(Point(aCanvasArea.X, aCanvasArea.Y), Size(aCanvasArea.Width, aCanvasArea.Height)); SAL_INFO("slideshow.opengl", "canvas area: " << aCanvasArea.X << "," << aCanvasArea.Y << " - " << aCanvasArea.Width << "x" << aCanvasArea.Height); @@ -375,10 +380,12 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta mbGenerateMipmap = rGLWindow.HasGLExtension( "GL_SGIS_generate_mipmap" ); + CHECK_GL_ERROR(); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glClearColor (0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); + CHECK_GL_ERROR(); mpContext->swapBuffers(); @@ -391,6 +398,7 @@ bool OGLTransitionerImpl::initWindowFromSlideShowView( const Reference< presenta glEnable(GL_NORMALIZE); glViewport(0, 0, aCanvasArea.Width, aCanvasArea.Height); + CHECK_GL_ERROR(); return true; } @@ -424,7 +432,9 @@ void OGLTransitionerImpl::impl_prepareSlides() aSlideRect.Y1 = 0; aSlideRect.Y2 = maSlideSize.Height; + CHECK_GL_ERROR(); mpContext->sync(); + CHECK_GL_ERROR(); mbUseLeavingPixmap = false; mbUseEnteringPixmap = false; @@ -508,12 +518,14 @@ void OGLTransitionerImpl::impl_prepareSlides() if( !mbUseEnteringPixmap ) maEnteringBytes = mxEnteringBitmap->getData(maSlideBitmapLayout, aSlideRect); + CHECK_GL_ERROR(); GLInitSlides(); SAL_WARN_IF(maSlideBitmapLayout.PlaneStride != 0, "slideshow.opengl","only handle no plane stride now"); mpContext->sync(); + CHECK_GL_ERROR(); #if defined( UNX ) && !defined( MACOSX ) // synchronized X still gives us much smoother play // I suspect some issues in above code in slideshow @@ -555,11 +567,13 @@ void OGLTransitionerImpl::createTexture( GLuint* texID, uno::Sequence<sal_Int8>& data, const OGLFormat* pFormat ) { + CHECK_GL_ERROR(); glDeleteTextures( 1, texID ); glGenTextures( 1, texID ); glBindTexture( GL_TEXTURE_2D, *texID ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); + CHECK_GL_ERROR(); #if defined( GLX_EXT_texture_from_pixmap ) if( usePixmap ) { @@ -581,6 +595,7 @@ void OGLTransitionerImpl::createTexture( GLuint* texID, impl_createTexture( useMipmap, data, pFormat ); #endif SAL_WARN_IF(!glIsTexture(*texID), "slideshow.opengl", "Can't generate Leaving slide textures in OpenGL"); + CHECK_GL_ERROR(); } namespace @@ -944,6 +959,7 @@ void OGLTransitionerImpl::impl_createTexture( { if( !pFormat ) { + CHECK_GL_ERROR(); // force-convert color to ARGB8888 int color space uno::Sequence<sal_Int8> tempBytes( maSlideBitmapLayout.ColorSpace->convertToIntegerColorSpace( @@ -979,10 +995,12 @@ void OGLTransitionerImpl::impl_createTexture( glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy ); } } + CHECK_GL_ERROR(); } void OGLTransitionerImpl::prepareEnvironment() { + CHECK_GL_ERROR(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); double EyePos(10.0); @@ -1006,6 +1024,7 @@ void OGLTransitionerImpl::prepareEnvironment() glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslated(0,0,-EyePos); + CHECK_GL_ERROR(); } const OGLFormat* OGLTransitionerImpl::chooseFormats() @@ -1147,6 +1166,7 @@ void OGLTransitionerImpl::GLInitSlides() if( !mbUseLeavingPixmap || !mbUseEnteringPixmap ) pFormat = chooseFormats(); + CHECK_GL_ERROR(); createTexture( &maLeavingSlideGL, #if defined( GLX_EXT_texture_from_pixmap ) maLeavingPixmapGL, @@ -1165,7 +1185,9 @@ void OGLTransitionerImpl::GLInitSlides() maEnteringBytes, pFormat ); + CHECK_GL_ERROR(); mpContext->sync(); + CHECK_GL_ERROR(); } void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeException, std::exception) @@ -1183,6 +1205,7 @@ void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeExc if (isDisposed() || !mbValidOpenGLContext || mpTransition->getSettings().mnRequiredGLVersion > mnGLVersion) return; + CHECK_GL_ERROR(); mpContext->makeCurrent(); glEnable(GL_DEPTH_TEST); @@ -1201,6 +1224,7 @@ void SAL_CALL OGLTransitionerImpl::update( double nTime ) throw (uno::RuntimeExc mpContext->show(); mpContext->sync(); + CHECK_GL_ERROR(); #if OSL_DEBUG_LEVEL > 1 maUpdateEndTime = microsec_clock::local_time(); @@ -1228,6 +1252,7 @@ void SAL_CALL OGLTransitionerImpl::viewChanged( const Reference< presentation::X void OGLTransitionerImpl::disposeTextures() { + CHECK_GL_ERROR(); mpContext->makeCurrent(); #if defined( GLX_EXT_texture_from_pixmap ) @@ -1266,6 +1291,7 @@ void OGLTransitionerImpl::disposeTextures() mbUseLeavingPixmap = false; mbUseEnteringPixmap = false; + CHECK_GL_ERROR(); } void OGLTransitionerImpl::impl_dispose() |