~ubuntu-branches/ubuntu/oneiric/nux/oneiric

« back to all changes in this revision

Viewing changes to NuxGraphics/IOpenGLGLSLShader.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-06-22 17:16:16 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20110622171616-3cyhhiwsb6ga9d30
Tags: 1.0.2-0ubuntu1
* New upstream release.
* Cherry-pick a fix for FTBFS with -fpermissive
* debian/control:
  - add new libxdamage-dev and libxcomposite-dev build-dep
  - add new libboost1.42-dev dep as well, should be transitionned to 1.46 once
    compiz is transitionned as well
* remove debian/patches/01_build_with_gcc46.patch as included upstream
* debian/rules:
  - disable google code tests while building
* debian/control, debian/rules, debian/libnux-1.0-common.install,
  debian/libnux-1.0-dev.install, debian/libnux-1.0-doc.install,
  debian/libnux-1.0-0.install:
  - change, prepare next ABI breakage and remove no more needed Breaks: with
    new soname bump
* libnux-1.0-common now replaces: libnux-0.9-common for the apport hook

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 *
20
20
 */
21
21
 
22
 
 
 
22
#include "GLResource.h"
 
23
#include "GraphicsDisplay.h"
23
24
#include "GpuDevice.h"
24
25
#include "GLDeviceObjects.h"
25
26
#include "IOpenGLGLSLShader.h"
26
27
 
27
28
namespace nux
28
29
{
29
 
 
30
30
  NUX_IMPLEMENT_OBJECT_TYPE (IOpenGLShader);
31
31
  NUX_IMPLEMENT_OBJECT_TYPE (IOpenGLVertexShader);
32
32
  NUX_IMPLEMENT_OBJECT_TYPE (IOpenGLPixelShader);
33
33
  NUX_IMPLEMENT_OBJECT_TYPE (IOpenGLShaderProgram);
34
34
 
35
 
  struct ShaderDefinition
36
 
  {
37
 
    NString         Name;
38
 
    NString     Value;
39
 
  };
40
 
 
41
 
// //-----------------------------------------------------------------------------
42
 
// static void AddShaderDefinition(std::vector<ShaderDefinition>& Definitions,const TCHAR* Name,const TCHAR* Format,...)
43
 
// {
44
 
//     TCHAR    DefinitionText[1024];
45
 
//     GET_VARARGS(DefinitionText, NUX_ARRAY_COUNT(DefinitionText), NUX_ARRAY_COUNT(DefinitionText)-1,Format);
46
 
//
47
 
//     ShaderDefinition Definition;
48
 
//     Definition.Name = Name;
49
 
//     Definition.Value = DefinitionText;
50
 
//     Definitions.push_back(Definition);
51
 
// }
52
 
 
53
 
//-----------------------------------------------------------------------------
54
35
  bool ExtractShaderString3 (const NString &ShaderToken, const NString &ShaderSource, NString &RetSource, NString ShaderPreprocessorDefines)
55
36
  {
56
37
    t_size lineStart = 0;
394
375
    NString PixelShaderSource;
395
376
    ExtractShaderString3 (TEXT ("[Fragment Shader]"), ShaderCode, PixelShaderSource, NString (FrgShaderPreprocessorDefines) );
396
377
 
397
 
    ObjectPtr<IOpenGLVertexShader> vs = GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader;
398
 
    ObjectPtr<IOpenGLPixelShader> ps = GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader;
 
378
    ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader;
 
379
    ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader;
399
380
 
400
381
    vs->SetShaderCode (&VertexShaderSource[0]);
401
382
    ps->SetShaderCode (&PixelShaderSource[0]);
412
393
  {
413
394
    nuxAssertMsg (glslshader, TEXT ("[IOpenGLShaderProgram::LoadVertexShader] Invalid shader code.") );
414
395
    NUX_RETURN_IF_NULL (glslshader);
415
 
    ObjectPtr<IOpenGLVertexShader> vs = GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader;
 
396
    ObjectPtr<IOpenGLVertexShader> vs = GetGraphicsDisplay()->GetGpuDevice()->CreateVertexShader(); //new IOpenGLVertexShader;
416
397
 
417
398
    NString ProcessedShaderSource;
418
399
    NString Defines (VtxShaderPreprocessorDefines);
427
408
  {
428
409
    nuxAssertMsg (glslshader, TEXT ("[IOpenGLShaderProgram::LoadPixelShader] Invalid shader code.") );
429
410
    NUX_RETURN_IF_NULL (glslshader);
430
 
    ObjectPtr<IOpenGLPixelShader> ps = GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader;
 
411
    ObjectPtr<IOpenGLPixelShader> ps = GetGraphicsDisplay()->GetGpuDevice()->CreatePixelShader(); //new IOpenGLPixelShader;
431
412
 
432
413
    NString ProcessedShaderSource;
433
414
    NString Defines (FrgShaderPreprocessorDefines);
561
542
    m_CompiledAndReady = true;
562
543
 
563
544
    Begin();
 
545
    CheckUniformLocation();
564
546
    CheckAttributeLocation();
565
 
    CheckUniformLocation();
 
547
    
566
548
    End();
567
549
 
568
550
    return m_CompiledAndReady;
636
618
                            &type,
637
619
                            active_attribute_name);
638
620
      CHECKGL_MSG ( glGetActiveAttribARB );
639
 
      m_ProgramAttributeDefinition[index].attribute_index = index;
 
621
      m_ProgramAttributeDefinition[index].attribute_index = glGetAttribLocationARB(_OpenGLID, active_attribute_name);
 
622
      CHECKGL_MSG ( glGetAttribLocationARB );
640
623
      m_ProgramAttributeDefinition[index].attribute_name = active_attribute_name;
641
624
      m_ProgramAttributeDefinition[index].valid = true;
642
625
 
663
646
          nuxAssert (0);
664
647
      }
665
648
    }
666
 
 
667
 
 
668
 
    //    if(sad == 0)
669
 
    //        return;
670
 
    //    int n = sizeof(sad) / sizeof(IOpenGLShaderAttributeDefinition);
671
 
    //    for(int i = 0; i < num_active_attributes; i++)
672
 
    //    {
673
 
    //        bool found = false;
674
 
    //        for(int j = 0; j < n; j++)
675
 
    //        {
676
 
    //            if(m_ProgramAttributeDefinition[i].attribute_name == sad[j].attribute_name)
677
 
    //            {
678
 
    //                found = true;
679
 
    //                if(m_ProgramAttributeDefinition[i].attribute_index != sad[j].attribute_index)
680
 
    //                    OutputDebugString("*** Active attribute has incorrect index.\n");
681
 
    //                if(m_ProgramAttributeDefinition[i].type != sad[j].type)
682
 
    //                    OutputDebugString("*** Active attribute has incorrect type.\n");
683
 
    //                break;
684
 
    //            }
685
 
    //            if(found == false)
686
 
    //            {
687
 
    //                OutputDebugString("*** Active binded but not requested in meta shader info.\n");
688
 
    //                nuxAssert(0);
689
 
    //            }
690
 
    //        }
691
 
    //    }
692
 
    //
693
 
    //
694
 
    //    for(int i = 0; i < n; i++)
695
 
    //    {
696
 
    //        bool found = false;
697
 
    //        for(int j = 0; j < num_active_attributes; j++)
698
 
    //        {
699
 
    //            if(sad[i].attribute_name == m_ProgramAttributeDefinition[j].attribute_name)
700
 
    //            {
701
 
    //                found = true;
702
 
    //                if(sad[i].attribute_index != m_ProgramAttributeDefinition[j].attribute_index)
703
 
    //                    OutputDebugString("*** Active attribute has incorrect index.\n");
704
 
    //                if(sad[i].type != m_ProgramAttributeDefinition[j].type)
705
 
    //                    OutputDebugString("*** Active attribute has incorrect type.\n");
706
 
    //                break;
707
 
    //            }
708
 
    //            if(found == false)
709
 
    //            {
710
 
    //                OutputDebugString("*** Active requested in meta shader info but not binded.\n");
711
 
    //                nuxAssert(0);
712
 
    //            }
713
 
    //        }
714
 
    //    }
715
649
  }
716
650
 
717
651
  void IOpenGLShaderProgram::CheckUniformLocation()
730
664
        nuxAssert (0);
731
665
      }
732
666
 
733
 
      //GLsizei length;
734
667
      GLint size = 0;
735
668
      GLenum type = 0;
736
669
 
737
670
      if (location >= 0)
738
671
      {
739
 
        //nuxDebugMsg(TEXT("[IOpenGLShaderProgram::CheckUniformLocation] Program OpenGL ID: %d"), _OpenGLID);
740
 
        //nuxDebugMsg(TEXT("[IOpenGLShaderProgram::CheckUniformLocation] Location index:%s %d"), TCHAR_TO_ANSI(parameter->m_Name.GetTCharPtr()), location);
741
672
        CHECKGL ( glGetActiveUniformARB (_OpenGLID, location, 0, NULL /*&length*/, &size, &type, NULL) );
742
673
      }
743
674
 
760
691
    return -1;
761
692
  }
762
693
 
763
 
//-----------------------------------------------------------------------------
764
694
  bool IOpenGLShaderProgram::SetUniform1f (char *varname, GLfloat v0)
765
695
  {
766
 
    //if (!useGLSL) return false; // GLSL not available
767
 
    //if (!_noshader) return true;
768
 
 
769
696
    GLint loc = GetUniformLocationARB (varname);
770
697
 
771
698
    if (loc == -1) return false; // can't find variable
776
703
  }
777
704
  bool IOpenGLShaderProgram::SetUniform1f (GLint loc, GLfloat v0)
778
705
  {
779
 
    //if (!useGLSL) return false; // GLSL not available
780
 
    //if (!_noshader) return true;
781
 
 
782
706
    if (loc == -1) return false; // can't find variable
783
707
 
784
708
    glUniform1fARB (loc, v0);
785
709
    return true;
786
710
  }
787
711
 
788
 
//-----------------------------------------------------------------------------
789
712
 
790
713
  bool IOpenGLShaderProgram::SetUniform2f (char *varname, GLfloat v0, GLfloat v1)
791
714
  {
792
 
    //if (!useGLSL) return false; // GLSL not available
793
 
    //if (!_noshader) return true;
794
 
 
795
715
    GLint loc = GetUniformLocationARB (varname);
796
716
 
797
717
    if (loc == -1) return false; // can't find variable
802
722
  }
803
723
  bool IOpenGLShaderProgram::SetUniform2f (GLint loc, GLfloat v0, GLfloat v1)
804
724
  {
805
 
    //if (!useGLSL) return false; // GLSL not available
806
 
    //if (!_noshader) return true;
807
 
 
808
725
    if (loc == -1) return false; // can't find variable
809
726
 
810
727
    glUniform2fARB (loc, v0, v1);
811
728
    return true;
812
729
  }
813
 
//-----------------------------------------------------------------------------
814
730
 
815
731
  bool IOpenGLShaderProgram::SetUniform3f (char *varname, GLfloat v0, GLfloat v1, GLfloat v2)
816
732
  {
817
 
    //if (!useGLSL) return false; // GLSL not available
818
 
    //if (!_noshader) return true;
819
 
 
820
733
    GLint loc = GetUniformLocationARB (varname);
821
734
 
822
735
    if (loc == -1) return false; // can't find variable
827
740
  }
828
741
  bool IOpenGLShaderProgram::SetUniform3f (GLint loc, GLfloat v0, GLfloat v1, GLfloat v2)
829
742
  {
830
 
    //if (!useGLSL) return false; // GLSL not available
831
 
    //if (!_noshader) return true;
832
 
 
833
743
    if (loc == -1) return false; // can't find variable
834
744
 
835
745
    glUniform3fARB (loc, v0, v1, v2);
836
746
 
837
747
    return true;
838
748
  }
839
 
//-----------------------------------------------------------------------------
840
749
 
841
750
  bool IOpenGLShaderProgram::SetUniform4f (char *varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
842
751
  {
843
 
    //if (!useGLSL) return false; // GLSL not available
844
 
    //if (!_noshader) return true;
845
 
 
846
752
    GLint loc = GetUniformLocationARB (varname);
847
753
 
848
754
    if (loc == -1) return false; // can't find variable
853
759
  }
854
760
  bool IOpenGLShaderProgram::SetUniform4f (GLint loc, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
855
761
  {
856
 
    //if (!useGLSL) return false; // GLSL not available
857
 
    //if (!_noshader) return true;
858
 
 
859
762
    if (loc == -1) return false; // can't find variable
860
763
 
861
764
    glUniform4fARB (loc, v0, v1, v2, v3);
862
765
 
863
766
    return true;
864
767
  }
865
 
//-----------------------------------------------------------------------------
866
768
 
867
769
  bool IOpenGLShaderProgram::SetUniform1i (char *varname, GLint v0)
868
770
  {
869
 
    //if (!useGLSL) return false; // GLSL not available
870
 
    //if (!_noshader) return true;
871
 
 
872
771
    GLint loc = GetUniformLocationARB (varname);
873
772
 
874
773
    if (loc == -1) return false; // can't find variable
879
778
  }
880
779
  bool IOpenGLShaderProgram::SetUniform1i (GLint loc, GLint v0)
881
780
  {
882
 
    //if (!useGLSL) return false; // GLSL not available
883
 
    //if (!_noshader) return true;
884
 
 
885
781
    if (loc == -1) return false; // can't find variable
886
782
 
887
783
    glUniform1iARB (loc, v0);
891
787
 
892
788
  bool IOpenGLShaderProgram::SetUniform2i (char *varname, GLint v0, GLint v1)
893
789
  {
894
 
    //    if (!useGLSL) return false; // GLSL not available
895
 
    //    if (!_noshader) return true;
896
 
 
897
790
    GLint loc = GetUniformLocationARB (varname);
898
791
 
899
792
    if (loc == -1) return false; // can't find variable
905
798
  }
906
799
  bool IOpenGLShaderProgram::SetUniform2i (GLint loc, GLint v0, GLint v1)
907
800
  {
908
 
    //    if (!useGLSL) return false; // GLSL not available
909
 
    //    if (!_noshader) return true;
910
 
 
911
801
    if (loc == -1) return false; // can't find variable
912
802
 
913
803
    glUniform2iARB (loc, v0, v1);
915
805
 
916
806
    return true;
917
807
  }
918
 
//-----------------------------------------------------------------------------
919
808
 
920
809
  bool IOpenGLShaderProgram::SetUniform3i (char *varname, GLint v0, GLint v1, GLint v2)
921
810
  {
922
 
    //    if (!useGLSL) return false; // GLSL not available
923
 
    //    if (!_noshader) return true;
924
 
 
925
811
    GLint loc = GetUniformLocationARB (varname);
926
812
 
927
813
    if (loc == -1) return false; // can't find variable
932
818
  }
933
819
  bool IOpenGLShaderProgram::SetUniform3i (GLint loc, GLint v0, GLint v1, GLint v2)
934
820
  {
935
 
    //    if (!useGLSL) return false; // GLSL not available
936
 
    //    if (!_noshader) return true;
937
 
 
938
821
    if (loc == -1) return false; // can't find variable
939
822
 
940
823
    glUniform3iARB (loc, v0, v1, v2);
944
827
 
945
828
  bool IOpenGLShaderProgram::SetUniform4i (char *varname, GLint v0, GLint v1, GLint v2, GLint v3)
946
829
  {
947
 
    //    if (!useGLSL) return false; // GLSL not available
948
 
    //    if (!_noshader) return true;
949
 
 
950
830
    GLint loc = GetUniformLocationARB (varname);
951
831
 
952
832
    if (loc == -1) return false; // can't find variable
957
837
  }
958
838
  bool IOpenGLShaderProgram::SetUniform4i (GLint loc, GLint v0, GLint v1, GLint v2, GLint v3)
959
839
  {
960
 
    //    if (!useGLSL) return false; // GLSL not available
961
 
    //    if (!_noshader) return true;
962
 
 
963
840
    if (loc == -1) return false; // can't find variable
964
841
 
965
842
    glUniform4iARB (loc, v0, v1, v2, v3);
966
843
 
967
844
    return true;
968
845
  }
969
 
//-----------------------------------------------------------------------------
970
846
 
971
847
  bool IOpenGLShaderProgram::SetUniform1fv (char *varname, GLsizei count, GLfloat *value)
972
848
  {
973
 
    //    if (!useGLSL) return false; // GLSL not available
974
 
    //    if (!_noshader) return true;
975
 
 
976
849
    GLint loc = GetUniformLocationARB (varname);
977
850
 
978
851
    if (loc == -1) return false; // can't find variable
983
856
  }
984
857
  bool IOpenGLShaderProgram::SetUniform1fv (GLint loc, GLsizei count, GLfloat *value)
985
858
  {
986
 
    //    if (!useGLSL) return false; // GLSL not available
987
 
    //    if (!_noshader) return true;
988
 
 
989
859
    if (loc == -1) return false; // can't find variable
990
860
 
991
861
    glUniform1fvARB (loc, count, value);
995
865
 
996
866
  bool IOpenGLShaderProgram::SetUniform2fv (char *varname, GLsizei count, GLfloat *value)
997
867
  {
998
 
    //    if (!useGLSL) return false; // GLSL not available
999
 
    //    if (!_noshader) return true;
1000
 
 
1001
868
    GLint loc = GetUniformLocationARB (varname);
1002
869
 
1003
870
    if (loc == -1) return false; // can't find variable
1008
875
  }
1009
876
  bool IOpenGLShaderProgram::SetUniform2fv (GLint loc, GLsizei count, GLfloat *value)
1010
877
  {
1011
 
    //    if (!useGLSL) return false; // GLSL not available
1012
 
    //    if (!_noshader) return true;
1013
 
 
1014
878
    if (loc == -1) return false; // can't find variable
1015
879
 
1016
880
    glUniform2fvARB (loc, count, value);
1017
881
 
1018
882
    return true;
1019
883
  }
1020
 
//-----------------------------------------------------------------------------
1021
884
 
1022
885
  bool IOpenGLShaderProgram::SetUniform3fv (char *varname, GLsizei count, GLfloat *value)
1023
886
  {
1024
 
    //    if (!useGLSL) return false; // GLSL not available
1025
 
    //    if (!_noshader) return true;
1026
 
 
1027
887
    GLint loc = GetUniformLocationARB (varname);
1028
888
 
1029
889
    if (loc == -1) return false; // can't find variable
1034
894
  }
1035
895
  bool IOpenGLShaderProgram::SetUniform3fv (GLint loc, GLsizei count, GLfloat *value)
1036
896
  {
1037
 
    //    if (!useGLSL) return false; // GLSL not available
1038
 
    //    if (!_noshader) return true;
1039
 
 
1040
897
    if (loc == -1) return false; // can't find variable
1041
898
 
1042
899
    glUniform3fvARB (loc, count, value);
1043
900
 
1044
901
    return true;
1045
902
  }
1046
 
//-----------------------------------------------------------------------------
1047
903
 
1048
904
  bool IOpenGLShaderProgram::SetUniform4fv (char *varname, GLsizei count, GLfloat *value)
1049
905
  {
1050
 
    //    if (!useGLSL) return false; // GLSL not available
1051
 
    //    if (!_noshader) return true;
1052
 
 
1053
906
    GLint loc = GetUniformLocationARB (varname);
1054
907
 
1055
908
    if (loc == -1) return false; // can't find variable
1060
913
  }
1061
914
  bool IOpenGLShaderProgram::SetUniform4fv (GLint loc, GLsizei count, GLfloat *value)
1062
915
  {
1063
 
    //    if (!useGLSL) return false; // GLSL not available
1064
 
    //    if (!_noshader) return true;
1065
 
 
1066
916
    if (loc == -1) return false; // can't find variable
1067
917
 
1068
918
    glUniform4fvARB (loc, count, value);
1069
919
 
1070
920
    return true;
1071
921
  }
1072
 
//-----------------------------------------------------------------------------
1073
922
 
1074
923
  bool IOpenGLShaderProgram::SetUniform1iv (char *varname, GLsizei count, GLint *value)
1075
924
  {
1076
 
    //    if (!useGLSL) return false; // GLSL not available
1077
 
    //    if (!_noshader) return true;
1078
 
 
1079
925
    GLint loc = GetUniformLocationARB (varname);
1080
926
 
1081
927
    if (loc == -1) return false; // can't find variable
1086
932
  }
1087
933
  bool IOpenGLShaderProgram::SetUniform1iv (GLint loc, GLsizei count, GLint *value)
1088
934
  {
1089
 
    //    if (!useGLSL) return false; // GLSL not available
1090
 
    //    if (!_noshader) return true;
1091
 
 
1092
935
    if (loc == -1) return false; // can't find variable
1093
936
 
1094
937
    glUniform1ivARB (loc, count, value);
1095
938
 
1096
939
    return true;
1097
940
  }
1098
 
//-----------------------------------------------------------------------------
1099
941
 
1100
942
  bool IOpenGLShaderProgram::SetUniform2iv (char *varname, GLsizei count, GLint *value)
1101
943
  {
1102
 
    //    if (!useGLSL) return false; // GLSL not available
1103
 
    //    if (!_noshader) return true;
1104
 
 
1105
944
    GLint loc = GetUniformLocationARB (varname);
1106
945
 
1107
946
    if (loc == -1) return false; // can't find variable
1112
951
  }
1113
952
  bool IOpenGLShaderProgram::SetUniform2iv (GLint loc, GLsizei count, GLint *value)
1114
953
  {
1115
 
    //    if (!useGLSL) return false; // GLSL not available
1116
 
    //    if (!_noshader) return true;
1117
 
 
1118
954
    if (loc == -1) return false; // can't find variable
1119
955
 
1120
956
    glUniform2ivARB (loc, count, value);
1121
957
 
1122
958
    return true;
1123
959
  }
1124
 
//-----------------------------------------------------------------------------
1125
960
 
1126
961
  bool IOpenGLShaderProgram::SetUniform3iv (char *varname, GLsizei count, GLint *value)
1127
962
  {
1128
 
    //    if (!useGLSL) return false; // GLSL not available
1129
 
    //    if (!_noshader) return true;
1130
 
 
1131
963
    GLint loc = GetUniformLocationARB (varname);
1132
964
 
1133
965
    if (loc == -1) return false; // can't find variable
1138
970
  }
1139
971
  bool IOpenGLShaderProgram::SetUniform3iv (GLint loc, GLsizei count, GLint *value)
1140
972
  {
1141
 
    //    if (!useGLSL) return false; // GLSL not available
1142
 
    //    if (!_noshader) return true;
1143
 
 
1144
973
    if (loc == -1) return false; // can't find variable
1145
974
 
1146
975
    glUniform3ivARB (loc, count, value);
1147
976
 
1148
977
    return true;
1149
978
  }
1150
 
//-----------------------------------------------------------------------------
1151
979
 
1152
980
  bool IOpenGLShaderProgram::SetUniform4iv (char *varname, GLsizei count, GLint *value)
1153
981
  {
1154
 
    //    if (!useGLSL) return false; // GLSL not available
1155
 
    //    if (!_noshader) return true;
1156
 
 
1157
982
    GLint loc = GetUniformLocationARB (varname);
1158
983
 
1159
984
    if (loc == -1) return false; // can't find variable
1164
989
  }
1165
990
  bool IOpenGLShaderProgram::SetUniform4iv (GLint loc, GLsizei count, GLint *value)
1166
991
  {
1167
 
    //    if (!useGLSL) return false; // GLSL not available
1168
 
    //    if (!_noshader) return true;
1169
 
 
1170
992
    if (loc == -1) return false; // can't find variable
1171
993
 
1172
994
    glUniform4ivARB (loc, count, value);
1173
995
 
1174
996
    return true;
1175
997
  }
1176
 
//-----------------------------------------------------------------------------
1177
998
 
1178
999
  bool IOpenGLShaderProgram::SetUniformMatrix2fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
1179
1000
  {
1180
 
    //    if (!useGLSL) return false; // GLSL not available
1181
 
    //    if (!_noshader) return true;
1182
 
 
1183
1001
    GLint loc = GetUniformLocationARB (varname);
1184
1002
 
1185
1003
    if (loc == -1) return false; // can't find variable
1190
1008
  }
1191
1009
  bool IOpenGLShaderProgram::SetUniformLocMatrix2fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
1192
1010
  {
1193
 
    //    if (!useGLSL) return false; // GLSL not available
1194
 
    //    if (!_noshader) return true;
1195
 
 
1196
1011
    if (loc == -1) return false; // can't find variable
1197
1012
 
1198
1013
    glUniformMatrix2fvARB (loc, count, transpose, value);
1199
1014
 
1200
1015
    return true;
1201
1016
  }
1202
 
//-----------------------------------------------------------------------------
1203
1017
 
1204
1018
  bool IOpenGLShaderProgram::SetUniformMatrix3fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
1205
1019
  {
1206
 
    //    if (!useGLSL) return false; // GLSL not available
1207
 
    //    if (!_noshader) return true;
1208
 
 
1209
1020
    GLint loc = GetUniformLocationARB (varname);
1210
1021
 
1211
1022
    if (loc == -1) return false; // can't find variable
1216
1027
  }
1217
1028
  bool IOpenGLShaderProgram::SetUniformLocMatrix3fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
1218
1029
  {
1219
 
    //    if (!useGLSL) return false; // GLSL not available
1220
 
    //    if (!_noshader) return true;
1221
 
 
1222
1030
    if (loc == -1) return false; // can't find variable
1223
1031
 
1224
1032
    glUniformMatrix3fvARB (loc, count, transpose, value);
1225
1033
 
1226
1034
    return true;
1227
1035
  }
1228
 
//-----------------------------------------------------------------------------
1229
1036
 
1230
1037
  bool IOpenGLShaderProgram::SetUniformMatrix4fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
1231
1038
  {
1232
 
    //    if (!useGLSL) return false; // GLSL not available
1233
 
    //    if (!_noshader) return true;
1234
 
 
1235
1039
    GLint loc = GetUniformLocationARB (varname);
1236
1040
 
1237
1041
    if (loc == -1) return false; // can't find variable
1242
1046
  }
1243
1047
  bool IOpenGLShaderProgram::SetUniformLocMatrix4fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
1244
1048
  {
1245
 
    //    if (!useGLSL) return false; // GLSL not available
1246
 
    //    if (!_noshader) return true;
1247
 
 
1248
1049
    if (loc == -1) return false; // can't find variable
1249
1050
 
1250
1051
    glUniformMatrix4fvARB (loc, count, transpose, value);
1252
1053
    return true;
1253
1054
  }
1254
1055
 
1255
 
//-----------------------------------------------------------------------------
1256
1056
 
1257
1057
  void IOpenGLShaderProgram::GetUniformfv (char *name, GLfloat *values)
1258
1058
  {
1259
 
    //     if (!useGLSL) return;
1260
1059
    GLint loc;
1261
1060
 
1262
1061
    loc = glGetUniformLocationARB (_OpenGLID, name);
1270
1069
    CHECKGL ( glGetUniformfvARB (_OpenGLID, loc, values) );
1271
1070
  }
1272
1071
 
1273
 
//-----------------------------------------------------------------------------
1274
1072
 
1275
1073
  void IOpenGLShaderProgram::GetUniformiv (char *name, GLint *values)
1276
1074
  {
1277
 
    //if (!useGLSL) return;
1278
1075
    GLint loc;
1279
1076
    loc = glGetUniformLocationARB (_OpenGLID, name);
1280
1077
    CHECKGL_MSG ( glGetUniformLocationARB );
1286
1083
 
1287
1084
    CHECKGL ( glGetUniformivARB (_OpenGLID, loc, values) );
1288
1085
  }
1289
 
//-----------------------------------------------------------------------------
1290
1086
 
1291
1087
  int IOpenGLShaderProgram::GetUniformLocationARB (const GLcharARB *name)
1292
1088
  {
1296
1092
    return loc;
1297
1093
  }
1298
1094
 
1299
 
//-----------------------------------------------------------------------------
1300
1095
  void IOpenGLShaderProgram::GetActiveUniformARB (
1301
1096
    GLuint index,
1302
1097
    GLsizei maxLength,
1316
1111
    CHECKGL_MSG (glGetActiveUniformARB);
1317
1112
  }
1318
1113
 
1319
 
//-----------------------------------------------------------------------------
1320
1114
 
1321
1115
  void IOpenGLShaderProgram::GetObjectParameterfvARB (GLenum pname,
1322
1116
      GLfloat *params)
1327
1121
    CHECKGL_MSG (glGetObjectParameterfvARB);
1328
1122
  }
1329
1123
 
1330
 
//-----------------------------------------------------------------------------
1331
 
 
1332
 
  BOOL IOpenGLShaderProgram::SetSampler (char *name, int texture_unit)
 
1124
  bool IOpenGLShaderProgram::SetSampler (char *name, int texture_unit)
1333
1125
  {
1334
1126
    GLint loc = GetUniformLocationARB (name);
1335
1127