LCOV - code coverage report
Current view: top level - libreoffice/slideshow/source/engine/OGLTrans/unx - OGLTrans_Shaders.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-12-27 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2008 by Sun Microsystems, Inc.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #include <osl/diagnose.hxx>
      30             : 
      31             : #include "OGLTrans_Shaders.hxx"
      32             : 
      33             : namespace unx
      34             : {
      35             : #include <GL/glx.h>
      36             : #include <GL/glxext.h>
      37             : }
      38             : 
      39             : bool OGLShaders::cbInitialized = false;
      40             : 
      41             : #ifdef GL_VERSION_2_0
      42             : 
      43             : PFNGLCREATESHADERPROC OGLShaders::glCreateShader = NULL;
      44             : PFNGLSHADERSOURCEPROC OGLShaders::glShaderSource = NULL;
      45             : PFNGLCOMPILESHADERPROC OGLShaders::glCompileShader = NULL;
      46             : PFNGLGETSHADERIVPROC OGLShaders::glGetShaderiv = NULL;
      47             : PFNGLGETSHADERINFOLOGPROC OGLShaders::glGetShaderInfoLog = NULL;
      48             : PFNGLDELETESHADERPROC OGLShaders::glDeleteShader = NULL;
      49             : PFNGLCREATEPROGRAMPROC OGLShaders::glCreateProgram = NULL;
      50             : PFNGLATTACHSHADERPROC OGLShaders::glAttachShader = NULL;
      51             : PFNGLLINKPROGRAMPROC OGLShaders::glLinkProgram = NULL;
      52             : PFNGLGETPROGRAMIVPROC OGLShaders::glGetProgramiv = NULL;
      53             : PFNGLGETPROGRAMINFOLOGPROC OGLShaders::glGetProgramInfoLog = NULL;
      54             : PFNGLUSEPROGRAMPROC OGLShaders::glUseProgram = NULL;
      55             : PFNGLDELETEPROGRAMPROC OGLShaders::glDeleteProgram = NULL;
      56             : PFNGLGETUNIFORMLOCATIONPROC OGLShaders::glGetUniformLocation = NULL;
      57             : PFNGLUNIFORM1IPROC OGLShaders::glUniform1i = NULL;
      58             : PFNGLUNIFORM1FPROC OGLShaders::glUniform1f = NULL;
      59             : #endif
      60             : 
      61           0 : bool OGLShaders::Initialize()
      62             : {
      63             : #ifdef GL_VERSION_2_0
      64           0 :     if( !cbInitialized ) {
      65           0 :         glCreateShader = (PFNGLCREATESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glCreateShader" );
      66           0 :         glShaderSource = (PFNGLSHADERSOURCEPROC) unx::glXGetProcAddress( (unsigned char *) "glShaderSource" );
      67           0 :         glCompileShader = (PFNGLCOMPILESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glCompileShader" );
      68           0 :         glGetShaderiv = (PFNGLGETSHADERIVPROC) unx::glXGetProcAddress( (unsigned char *) "glGetShaderiv" );
      69           0 :         glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) unx::glXGetProcAddress( (unsigned char *) "glGetShaderInfoLog" );
      70           0 :         glDeleteShader = (PFNGLDELETESHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glDeleteShader" );
      71           0 :         glCreateProgram = (PFNGLCREATEPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glCreateProgram" );
      72           0 :         glAttachShader = (PFNGLATTACHSHADERPROC) unx::glXGetProcAddress( (unsigned char *) "glAttachShader" );
      73           0 :         glLinkProgram = (PFNGLLINKPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glLinkProgram" );
      74           0 :         glGetProgramiv = (PFNGLGETPROGRAMIVPROC) unx::glXGetProcAddress( (unsigned char *) "glGetProgramiv" );
      75           0 :         glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) unx::glXGetProcAddress( (unsigned char *) "glGetProgramInfoLog" );
      76           0 :         glUseProgram = (PFNGLUSEPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glUseProgram" );
      77           0 :         glDeleteProgram = (PFNGLDELETEPROGRAMPROC) unx::glXGetProcAddress( (unsigned char *) "glDeleteProgram" );
      78           0 :         glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) unx::glXGetProcAddress( (unsigned char *) "glGetUniformLocation" );
      79           0 :         glUniform1i = (PFNGLUNIFORM1IPROC) unx::glXGetProcAddress( (unsigned char *) "glUniform1i" );
      80           0 :         glUniform1f = (PFNGLUNIFORM1FPROC) unx::glXGetProcAddress( (unsigned char *) "glUniform1f" );
      81           0 :         cbInitialized = true;
      82             :     }
      83             : 
      84           0 :     return glCreateShader != NULL;
      85             : #else
      86             :     return false;
      87             : #endif
      88             : }
      89             : 
      90           0 : GLuint OGLShaders::LinkProgram( const char *vertexShader, const char *fragmentShader )
      91             : {
      92             : #ifdef GL_VERSION_2_0
      93           0 :     if( !Initialize() )
      94           0 :         return 0;
      95             : 
      96             :     GLhandleARB vertexObject, fragmentObject, programObject;
      97             :     GLint vertexCompiled, fragmentCompiled, programLinked;
      98             :     char log[1024];
      99             : 
     100           0 :     vertexObject = glCreateShader( GL_VERTEX_SHADER );
     101           0 :     fragmentObject = glCreateShader( GL_FRAGMENT_SHADER );
     102             :     SAL_INFO("slideshow.opengl", "checkpoint 1: shaders created (" << (glGetError() == GL_NO_ERROR) << ") vertex: " << vertexObject << " fragment: " << fragmentObject);
     103             : 
     104             : 
     105           0 :     glShaderSource( vertexObject, 1, &vertexShader, NULL );
     106           0 :     glShaderSource( fragmentObject, 1, &fragmentShader, NULL );
     107             : 
     108           0 :     glCompileShader( vertexObject );
     109           0 :     glGetShaderInfoLog( vertexObject, sizeof( log ), NULL, log );
     110             :     SAL_INFO("slideshow.opengl", "vertex compile log: " << log);
     111           0 :     glGetShaderiv( vertexObject, GL_COMPILE_STATUS, &vertexCompiled );
     112           0 :     glCompileShader( fragmentObject );
     113           0 :     glGetShaderInfoLog( fragmentObject, sizeof( log ), NULL, log );
     114             :     SAL_INFO("slideshow.opengl", "fragment compile log: " << log);
     115           0 :     glGetShaderiv( fragmentObject, GL_COMPILE_STATUS, &fragmentCompiled );
     116             : 
     117           0 :     if( !vertexCompiled || !fragmentCompiled )
     118           0 :         return 0;
     119             : 
     120             :     SAL_INFO("slideshow.opengl", "checkpoint 2: shaders compiled (" << (glGetError() == GL_NO_ERROR) << ')');
     121             : 
     122           0 :     programObject = glCreateProgram();
     123           0 :     glAttachShader( programObject, vertexObject );
     124           0 :     glAttachShader( programObject, fragmentObject );
     125             : 
     126           0 :     glLinkProgram( programObject );
     127           0 :     glGetProgramInfoLog( programObject, sizeof( log ), NULL, log );
     128             :     SAL_INFO("slideshow.opengl", "program link log: " << log);
     129           0 :     glGetProgramiv( programObject, GL_LINK_STATUS, &programLinked );
     130             : 
     131           0 :     if( !programLinked )
     132           0 :         return 0;
     133             : 
     134             :     SAL_INFO("slideshow.opengl", "checkpoint 3: program linked (" << (glGetError() == GL_NO_ERROR) << ')');
     135             : 
     136           0 :     return programObject;
     137             : #else
     138             :     return 0;
     139             : #endif
     140             : }
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10