Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5273 in orxonox.OLD


Ignore:
Timestamp:
Oct 1, 2005, 10:39:27 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: now shaders do not execute (segfault) on non-shader hardware

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure

    r5271 r5273  
    54465446echo "${ECHO_T}$ac_cv_lib_glew32_main" >&6
    54475447if test $ac_cv_lib_glew32_main = yes; then
    5448   echo "$as_me:$LINENO: checking for main in -lglew32s" >&5
    5449 echo $ECHO_N "checking for main in -lglew32s... $ECHO_C" >&6
    5450 if test "${ac_cv_lib_glew32s_main+set}" = set; then
    5451   echo $ECHO_N "(cached) $ECHO_C" >&6
    5452 else
    5453   ac_check_lib_save_LIBS=$LIBS
    5454 LIBS="-lglew32s  $LIBS"
    5455 cat >conftest.$ac_ext <<_ACEOF
    5456 /* confdefs.h.  */
    5457 _ACEOF
    5458 cat confdefs.h >>conftest.$ac_ext
    5459 cat >>conftest.$ac_ext <<_ACEOF
    5460 /* end confdefs.h.  */
    5461 
    5462 
    5463 int
    5464 main ()
    5465 {
    5466 main ();
    5467   ;
    5468   return 0;
    5469 }
    5470 _ACEOF
    5471 rm -f conftest.$ac_objext conftest$ac_exeext
    5472 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
    5473   (eval $ac_link) 2>conftest.er1
    5474   ac_status=$?
    5475   grep -v '^ *+' conftest.er1 >conftest.err
    5476   rm -f conftest.er1
    5477   cat conftest.err >&5
    5478   echo "$as_me:$LINENO: \$? = $ac_status" >&5
    5479   (exit $ac_status); } &&
    5480          { ac_try='test -z "$ac_c_werror_flag"
    5481                          || test ! -s conftest.err'
    5482   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    5483   (eval $ac_try) 2>&5
    5484   ac_status=$?
    5485   echo "$as_me:$LINENO: \$? = $ac_status" >&5
    5486   (exit $ac_status); }; } &&
    5487          { ac_try='test -s conftest$ac_exeext'
    5488   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
    5489   (eval $ac_try) 2>&5
    5490   ac_status=$?
    5491   echo "$as_me:$LINENO: \$? = $ac_status" >&5
    5492   (exit $ac_status); }; }; then
    5493   ac_cv_lib_glew32s_main=yes
    5494 else
    5495   echo "$as_me: failed program was:" >&5
    5496 sed 's/^/| /' conftest.$ac_ext >&5
    5497 
    5498 ac_cv_lib_glew32s_main=no
    5499 fi
    5500 rm -f conftest.err conftest.$ac_objext \
    5501       conftest$ac_exeext conftest.$ac_ext
    5502 LIBS=$ac_check_lib_save_LIBS
    5503 fi
    5504 echo "$as_me:$LINENO: result: $ac_cv_lib_glew32s_main" >&5
    5505 echo "${ECHO_T}$ac_cv_lib_glew32s_main" >&6
    5506 if test $ac_cv_lib_glew32s_main = yes; then
    55075448  FOUND_glew32=yes
    55085449fi
    55095450
    5510 fi
    5511 
    55125451    if test x$FOUND_glew32 = xyes ; then
    5513         LIBS="$LIBS -lglew32 -lglew32s"
     5452        LIBS="$LIBS -lglew32"
    55145453    else
    55155454         echo "------------------"
  • trunk/src/lib/graphics/shader.cc

    r5271 r5273  
    1919
    2020#include "stdlibincl.h"
     21#include "compiler.h"
    2122#include <stdio.h>
    2223#include "debug.h"
     
    4445
    4546   if (GLEW_ARB_shader_objects && GLEW_ARB_shading_language_100)
    46      this->shaderProgram = glCreateProgramObjectARB();
    47 
    48    if (vertexShaderFile != NULL)
    49      this->loadShaderProgramm(SHADER_VERTEX, vertexShaderFile);
    50    if (fragmentShaderFile != NULL)
    51      this->loadShaderProgramm(SHADER_FRAGMENT, fragmentShaderFile);
    52   try  {
    53    glLinkProgramARB(this->shaderProgram); }
    54   catch(GLenum errorCode)  {
    55    this->printError(this->shaderProgram); }
     47     {
     48       this->shaderProgram = glCreateProgramObjectARB();
     49
     50       if (vertexShaderFile != NULL)
     51         this->loadShaderProgramm(SHADER_VERTEX, vertexShaderFile);
     52       if (fragmentShaderFile != NULL)
     53         this->loadShaderProgramm(SHADER_FRAGMENT, fragmentShaderFile);
     54       try  {
     55         glLinkProgramARB(this->shaderProgram); }
     56       catch(GLenum errorCode)  {
     57         this->printError(this->shaderProgram); }
     58     }
     59   else
     60     {
     61       PRINTF(2)("Shaders are not supported on your hardware\n");
     62     }
    5663}
    5764
     
    6673  this->deleteProgram(SHADER_FRAGMENT);
    6774
    68   glDeleteObjectARB(this->fragmentShader);
    69   glDeleteObjectARB(this->vertexShader);
    70   glDeleteObjectARB(this->shaderProgram);
     75  if (this->fragmentShader != 0)
     76    glDeleteObjectARB(this->fragmentShader);
     77  if (this->vertexShader != 0)
     78    glDeleteObjectARB(this->vertexShader);
     79  if (this->shaderProgram != 0)
     80    glDeleteObjectARB(this->shaderProgram);
    7181}
    7282
     
    98108    shader = this->fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
    99109  }
    100   glShaderSourceARB(shader, 1, (const GLcharARB**)&program, NULL);
    101   try {
    102     glCompileShaderARB(shader);
    103   }
    104   catch (...)
    105   {
    106     this->printError(shader);
    107   }
    108   glAttachObjectARB(this->shaderProgram, shader);
    109   delete[] program;
    110 }
    111 
     110
     111  if (shader != 0)
     112    {
     113      glShaderSourceARB(shader, 1, (const GLcharARB**)&program, NULL);
     114      try {
     115        glCompileShaderARB(shader);
     116      }
     117      catch (...)
     118        {
     119          this->printError(shader);
     120        }
     121      glAttachObjectARB(this->shaderProgram, shader);
     122      delete[] program;
     123    }
     124}
    112125
    113126char* Shader::fileRead(const char* fileName)
     
    139152void Shader::activateShader()
    140153{
    141   glUseProgramObjectARB(this->shaderProgram);
     154  if (likely (this->shaderProgram != 0))
     155    glUseProgramObjectARB(this->shaderProgram);
    142156}
    143157
     
    150164void Shader::deleteProgram(SHADER_TYPE type)
    151165{
    152   if (type == SHADER_VERTEX)
     166  if (type == SHADER_VERTEX && this->vertexShader != 0)
    153167  {
    154168    delete[] this->vertexShaderFile;
     
    157171    this->vertexShader = 0;
    158172  }
    159   else if (type == SHADER_FRAGMENT)
     173  else if (type == SHADER_FRAGMENT && this->fragmentShader != 0)
    160174  {
    161175    delete[] this->fragmentShaderFile;
     
    171185void Shader::printError(GLenum program)
    172186{
     187  if (program == 0)
     188    return;
     189
    173190  int infologLength = 0;
    174191  int charsWritten  = 0;
     
    206223        PRINT(3)("%d: %s\n", i, this->fragmentShaderSource->getEntry(i));*/
    207224  }
    208 
    209 
    210 }
    211 
     225}
     226
Note: See TracChangeset for help on using the changeset viewer.