~unity-team/nux/nux-remove-glew-mx

« back to all changes in this revision

Viewing changes to NuxGraphics/IOpenGLGLSLShader.cpp

  • Committer: Jay Taoko
  • Date: 2011-05-30 02:54:31 UTC
  • mfrom: (353.1.1 nux)
  • Revision ID: jay.taoko@canonical.com-20110530025431-kpqcnbcq3apsfz92
* Object::Dispose() now does the same thing as Object::UnReference()
* Fixed memory leak in UXTheme::Load2DTextureFile
* Mesh Resource manager
    - Fixed mesh Resource manager pipeline
    - See example ProgObjMeshLoader

* Fixed GLSL Shaders in FontRendering.cpp
    - removed global variable USE_ARB_SHADERS and replaced with GraphicsEngine::UsingGLSLCodePath()

* Removing files IniFile.cpp/.h
* Removing files UIColorTheme.cpp/.h

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;
663
645
          nuxAssert (0);
664
646
      }
665
647
    }
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
648
  }
716
649
 
717
650
  void IOpenGLShaderProgram::CheckUniformLocation()
730
663
        nuxAssert (0);
731
664
      }
732
665
 
733
 
      //GLsizei length;
734
666
      GLint size = 0;
735
667
      GLenum type = 0;
736
668
 
737
669
      if (location >= 0)
738
670
      {
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
671
        CHECKGL ( glGetActiveUniformARB (_OpenGLID, location, 0, NULL /*&length*/, &size, &type, NULL) );
742
672
      }
743
673
 
760
690
    return -1;
761
691
  }
762
692
 
763
 
//-----------------------------------------------------------------------------
764
693
  bool IOpenGLShaderProgram::SetUniform1f (char *varname, GLfloat v0)
765
694
  {
766
 
    //if (!useGLSL) return false; // GLSL not available
767
 
    //if (!_noshader) return true;
768
 
 
769
695
    GLint loc = GetUniformLocationARB (varname);
770
696
 
771
697
    if (loc == -1) return false; // can't find variable
776
702
  }
777
703
  bool IOpenGLShaderProgram::SetUniform1f (GLint loc, GLfloat v0)
778
704
  {
779
 
    //if (!useGLSL) return false; // GLSL not available
780
 
    //if (!_noshader) return true;
781
 
 
782
705
    if (loc == -1) return false; // can't find variable
783
706
 
784
707
    glUniform1fARB (loc, v0);
785
708
    return true;
786
709
  }
787
710
 
788
 
//-----------------------------------------------------------------------------
789
711
 
790
712
  bool IOpenGLShaderProgram::SetUniform2f (char *varname, GLfloat v0, GLfloat v1)
791
713
  {
792
 
    //if (!useGLSL) return false; // GLSL not available
793
 
    //if (!_noshader) return true;
794
 
 
795
714
    GLint loc = GetUniformLocationARB (varname);
796
715
 
797
716
    if (loc == -1) return false; // can't find variable
802
721
  }
803
722
  bool IOpenGLShaderProgram::SetUniform2f (GLint loc, GLfloat v0, GLfloat v1)
804
723
  {
805
 
    //if (!useGLSL) return false; // GLSL not available
806
 
    //if (!_noshader) return true;
807
 
 
808
724
    if (loc == -1) return false; // can't find variable
809
725
 
810
726
    glUniform2fARB (loc, v0, v1);
811
727
    return true;
812
728
  }
813
 
//-----------------------------------------------------------------------------
814
729
 
815
730
  bool IOpenGLShaderProgram::SetUniform3f (char *varname, GLfloat v0, GLfloat v1, GLfloat v2)
816
731
  {
817
 
    //if (!useGLSL) return false; // GLSL not available
818
 
    //if (!_noshader) return true;
819
 
 
820
732
    GLint loc = GetUniformLocationARB (varname);
821
733
 
822
734
    if (loc == -1) return false; // can't find variable
827
739
  }
828
740
  bool IOpenGLShaderProgram::SetUniform3f (GLint loc, GLfloat v0, GLfloat v1, GLfloat v2)
829
741
  {
830
 
    //if (!useGLSL) return false; // GLSL not available
831
 
    //if (!_noshader) return true;
832
 
 
833
742
    if (loc == -1) return false; // can't find variable
834
743
 
835
744
    glUniform3fARB (loc, v0, v1, v2);
836
745
 
837
746
    return true;
838
747
  }
839
 
//-----------------------------------------------------------------------------
840
748
 
841
749
  bool IOpenGLShaderProgram::SetUniform4f (char *varname, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
842
750
  {
843
 
    //if (!useGLSL) return false; // GLSL not available
844
 
    //if (!_noshader) return true;
845
 
 
846
751
    GLint loc = GetUniformLocationARB (varname);
847
752
 
848
753
    if (loc == -1) return false; // can't find variable
853
758
  }
854
759
  bool IOpenGLShaderProgram::SetUniform4f (GLint loc, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
855
760
  {
856
 
    //if (!useGLSL) return false; // GLSL not available
857
 
    //if (!_noshader) return true;
858
 
 
859
761
    if (loc == -1) return false; // can't find variable
860
762
 
861
763
    glUniform4fARB (loc, v0, v1, v2, v3);
862
764
 
863
765
    return true;
864
766
  }
865
 
//-----------------------------------------------------------------------------
866
767
 
867
768
  bool IOpenGLShaderProgram::SetUniform1i (char *varname, GLint v0)
868
769
  {
869
 
    //if (!useGLSL) return false; // GLSL not available
870
 
    //if (!_noshader) return true;
871
 
 
872
770
    GLint loc = GetUniformLocationARB (varname);
873
771
 
874
772
    if (loc == -1) return false; // can't find variable
879
777
  }
880
778
  bool IOpenGLShaderProgram::SetUniform1i (GLint loc, GLint v0)
881
779
  {
882
 
    //if (!useGLSL) return false; // GLSL not available
883
 
    //if (!_noshader) return true;
884
 
 
885
780
    if (loc == -1) return false; // can't find variable
886
781
 
887
782
    glUniform1iARB (loc, v0);
891
786
 
892
787
  bool IOpenGLShaderProgram::SetUniform2i (char *varname, GLint v0, GLint v1)
893
788
  {
894
 
    //    if (!useGLSL) return false; // GLSL not available
895
 
    //    if (!_noshader) return true;
896
 
 
897
789
    GLint loc = GetUniformLocationARB (varname);
898
790
 
899
791
    if (loc == -1) return false; // can't find variable
905
797
  }
906
798
  bool IOpenGLShaderProgram::SetUniform2i (GLint loc, GLint v0, GLint v1)
907
799
  {
908
 
    //    if (!useGLSL) return false; // GLSL not available
909
 
    //    if (!_noshader) return true;
910
 
 
911
800
    if (loc == -1) return false; // can't find variable
912
801
 
913
802
    glUniform2iARB (loc, v0, v1);
915
804
 
916
805
    return true;
917
806
  }
918
 
//-----------------------------------------------------------------------------
919
807
 
920
808
  bool IOpenGLShaderProgram::SetUniform3i (char *varname, GLint v0, GLint v1, GLint v2)
921
809
  {
922
 
    //    if (!useGLSL) return false; // GLSL not available
923
 
    //    if (!_noshader) return true;
924
 
 
925
810
    GLint loc = GetUniformLocationARB (varname);
926
811
 
927
812
    if (loc == -1) return false; // can't find variable
932
817
  }
933
818
  bool IOpenGLShaderProgram::SetUniform3i (GLint loc, GLint v0, GLint v1, GLint v2)
934
819
  {
935
 
    //    if (!useGLSL) return false; // GLSL not available
936
 
    //    if (!_noshader) return true;
937
 
 
938
820
    if (loc == -1) return false; // can't find variable
939
821
 
940
822
    glUniform3iARB (loc, v0, v1, v2);
944
826
 
945
827
  bool IOpenGLShaderProgram::SetUniform4i (char *varname, GLint v0, GLint v1, GLint v2, GLint v3)
946
828
  {
947
 
    //    if (!useGLSL) return false; // GLSL not available
948
 
    //    if (!_noshader) return true;
949
 
 
950
829
    GLint loc = GetUniformLocationARB (varname);
951
830
 
952
831
    if (loc == -1) return false; // can't find variable
957
836
  }
958
837
  bool IOpenGLShaderProgram::SetUniform4i (GLint loc, GLint v0, GLint v1, GLint v2, GLint v3)
959
838
  {
960
 
    //    if (!useGLSL) return false; // GLSL not available
961
 
    //    if (!_noshader) return true;
962
 
 
963
839
    if (loc == -1) return false; // can't find variable
964
840
 
965
841
    glUniform4iARB (loc, v0, v1, v2, v3);
966
842
 
967
843
    return true;
968
844
  }
969
 
//-----------------------------------------------------------------------------
970
845
 
971
846
  bool IOpenGLShaderProgram::SetUniform1fv (char *varname, GLsizei count, GLfloat *value)
972
847
  {
973
 
    //    if (!useGLSL) return false; // GLSL not available
974
 
    //    if (!_noshader) return true;
975
 
 
976
848
    GLint loc = GetUniformLocationARB (varname);
977
849
 
978
850
    if (loc == -1) return false; // can't find variable
983
855
  }
984
856
  bool IOpenGLShaderProgram::SetUniform1fv (GLint loc, GLsizei count, GLfloat *value)
985
857
  {
986
 
    //    if (!useGLSL) return false; // GLSL not available
987
 
    //    if (!_noshader) return true;
988
 
 
989
858
    if (loc == -1) return false; // can't find variable
990
859
 
991
860
    glUniform1fvARB (loc, count, value);
995
864
 
996
865
  bool IOpenGLShaderProgram::SetUniform2fv (char *varname, GLsizei count, GLfloat *value)
997
866
  {
998
 
    //    if (!useGLSL) return false; // GLSL not available
999
 
    //    if (!_noshader) return true;
1000
 
 
1001
867
    GLint loc = GetUniformLocationARB (varname);
1002
868
 
1003
869
    if (loc == -1) return false; // can't find variable
1008
874
  }
1009
875
  bool IOpenGLShaderProgram::SetUniform2fv (GLint loc, GLsizei count, GLfloat *value)
1010
876
  {
1011
 
    //    if (!useGLSL) return false; // GLSL not available
1012
 
    //    if (!_noshader) return true;
1013
 
 
1014
877
    if (loc == -1) return false; // can't find variable
1015
878
 
1016
879
    glUniform2fvARB (loc, count, value);
1017
880
 
1018
881
    return true;
1019
882
  }
1020
 
//-----------------------------------------------------------------------------
1021
883
 
1022
884
  bool IOpenGLShaderProgram::SetUniform3fv (char *varname, GLsizei count, GLfloat *value)
1023
885
  {
1024
 
    //    if (!useGLSL) return false; // GLSL not available
1025
 
    //    if (!_noshader) return true;
1026
 
 
1027
886
    GLint loc = GetUniformLocationARB (varname);
1028
887
 
1029
888
    if (loc == -1) return false; // can't find variable
1034
893
  }
1035
894
  bool IOpenGLShaderProgram::SetUniform3fv (GLint loc, GLsizei count, GLfloat *value)
1036
895
  {
1037
 
    //    if (!useGLSL) return false; // GLSL not available
1038
 
    //    if (!_noshader) return true;
1039
 
 
1040
896
    if (loc == -1) return false; // can't find variable
1041
897
 
1042
898
    glUniform3fvARB (loc, count, value);
1043
899
 
1044
900
    return true;
1045
901
  }
1046
 
//-----------------------------------------------------------------------------
1047
902
 
1048
903
  bool IOpenGLShaderProgram::SetUniform4fv (char *varname, GLsizei count, GLfloat *value)
1049
904
  {
1050
 
    //    if (!useGLSL) return false; // GLSL not available
1051
 
    //    if (!_noshader) return true;
1052
 
 
1053
905
    GLint loc = GetUniformLocationARB (varname);
1054
906
 
1055
907
    if (loc == -1) return false; // can't find variable
1060
912
  }
1061
913
  bool IOpenGLShaderProgram::SetUniform4fv (GLint loc, GLsizei count, GLfloat *value)
1062
914
  {
1063
 
    //    if (!useGLSL) return false; // GLSL not available
1064
 
    //    if (!_noshader) return true;
1065
 
 
1066
915
    if (loc == -1) return false; // can't find variable
1067
916
 
1068
917
    glUniform4fvARB (loc, count, value);
1069
918
 
1070
919
    return true;
1071
920
  }
1072
 
//-----------------------------------------------------------------------------
1073
921
 
1074
922
  bool IOpenGLShaderProgram::SetUniform1iv (char *varname, GLsizei count, GLint *value)
1075
923
  {
1076
 
    //    if (!useGLSL) return false; // GLSL not available
1077
 
    //    if (!_noshader) return true;
1078
 
 
1079
924
    GLint loc = GetUniformLocationARB (varname);
1080
925
 
1081
926
    if (loc == -1) return false; // can't find variable
1086
931
  }
1087
932
  bool IOpenGLShaderProgram::SetUniform1iv (GLint loc, GLsizei count, GLint *value)
1088
933
  {
1089
 
    //    if (!useGLSL) return false; // GLSL not available
1090
 
    //    if (!_noshader) return true;
1091
 
 
1092
934
    if (loc == -1) return false; // can't find variable
1093
935
 
1094
936
    glUniform1ivARB (loc, count, value);
1095
937
 
1096
938
    return true;
1097
939
  }
1098
 
//-----------------------------------------------------------------------------
1099
940
 
1100
941
  bool IOpenGLShaderProgram::SetUniform2iv (char *varname, GLsizei count, GLint *value)
1101
942
  {
1102
 
    //    if (!useGLSL) return false; // GLSL not available
1103
 
    //    if (!_noshader) return true;
1104
 
 
1105
943
    GLint loc = GetUniformLocationARB (varname);
1106
944
 
1107
945
    if (loc == -1) return false; // can't find variable
1112
950
  }
1113
951
  bool IOpenGLShaderProgram::SetUniform2iv (GLint loc, GLsizei count, GLint *value)
1114
952
  {
1115
 
    //    if (!useGLSL) return false; // GLSL not available
1116
 
    //    if (!_noshader) return true;
1117
 
 
1118
953
    if (loc == -1) return false; // can't find variable
1119
954
 
1120
955
    glUniform2ivARB (loc, count, value);
1121
956
 
1122
957
    return true;
1123
958
  }
1124
 
//-----------------------------------------------------------------------------
1125
959
 
1126
960
  bool IOpenGLShaderProgram::SetUniform3iv (char *varname, GLsizei count, GLint *value)
1127
961
  {
1128
 
    //    if (!useGLSL) return false; // GLSL not available
1129
 
    //    if (!_noshader) return true;
1130
 
 
1131
962
    GLint loc = GetUniformLocationARB (varname);
1132
963
 
1133
964
    if (loc == -1) return false; // can't find variable
1138
969
  }
1139
970
  bool IOpenGLShaderProgram::SetUniform3iv (GLint loc, GLsizei count, GLint *value)
1140
971
  {
1141
 
    //    if (!useGLSL) return false; // GLSL not available
1142
 
    //    if (!_noshader) return true;
1143
 
 
1144
972
    if (loc == -1) return false; // can't find variable
1145
973
 
1146
974
    glUniform3ivARB (loc, count, value);
1147
975
 
1148
976
    return true;
1149
977
  }
1150
 
//-----------------------------------------------------------------------------
1151
978
 
1152
979
  bool IOpenGLShaderProgram::SetUniform4iv (char *varname, GLsizei count, GLint *value)
1153
980
  {
1154
 
    //    if (!useGLSL) return false; // GLSL not available
1155
 
    //    if (!_noshader) return true;
1156
 
 
1157
981
    GLint loc = GetUniformLocationARB (varname);
1158
982
 
1159
983
    if (loc == -1) return false; // can't find variable
1164
988
  }
1165
989
  bool IOpenGLShaderProgram::SetUniform4iv (GLint loc, GLsizei count, GLint *value)
1166
990
  {
1167
 
    //    if (!useGLSL) return false; // GLSL not available
1168
 
    //    if (!_noshader) return true;
1169
 
 
1170
991
    if (loc == -1) return false; // can't find variable
1171
992
 
1172
993
    glUniform4ivARB (loc, count, value);
1173
994
 
1174
995
    return true;
1175
996
  }
1176
 
//-----------------------------------------------------------------------------
1177
997
 
1178
998
  bool IOpenGLShaderProgram::SetUniformMatrix2fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
1179
999
  {
1180
 
    //    if (!useGLSL) return false; // GLSL not available
1181
 
    //    if (!_noshader) return true;
1182
 
 
1183
1000
    GLint loc = GetUniformLocationARB (varname);
1184
1001
 
1185
1002
    if (loc == -1) return false; // can't find variable
1190
1007
  }
1191
1008
  bool IOpenGLShaderProgram::SetUniformLocMatrix2fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
1192
1009
  {
1193
 
    //    if (!useGLSL) return false; // GLSL not available
1194
 
    //    if (!_noshader) return true;
1195
 
 
1196
1010
    if (loc == -1) return false; // can't find variable
1197
1011
 
1198
1012
    glUniformMatrix2fvARB (loc, count, transpose, value);
1199
1013
 
1200
1014
    return true;
1201
1015
  }
1202
 
//-----------------------------------------------------------------------------
1203
1016
 
1204
1017
  bool IOpenGLShaderProgram::SetUniformMatrix3fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
1205
1018
  {
1206
 
    //    if (!useGLSL) return false; // GLSL not available
1207
 
    //    if (!_noshader) return true;
1208
 
 
1209
1019
    GLint loc = GetUniformLocationARB (varname);
1210
1020
 
1211
1021
    if (loc == -1) return false; // can't find variable
1216
1026
  }
1217
1027
  bool IOpenGLShaderProgram::SetUniformLocMatrix3fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
1218
1028
  {
1219
 
    //    if (!useGLSL) return false; // GLSL not available
1220
 
    //    if (!_noshader) return true;
1221
 
 
1222
1029
    if (loc == -1) return false; // can't find variable
1223
1030
 
1224
1031
    glUniformMatrix3fvARB (loc, count, transpose, value);
1225
1032
 
1226
1033
    return true;
1227
1034
  }
1228
 
//-----------------------------------------------------------------------------
1229
1035
 
1230
1036
  bool IOpenGLShaderProgram::SetUniformMatrix4fv (char *varname, GLsizei count, GLboolean transpose, GLfloat *value)
1231
1037
  {
1232
 
    //    if (!useGLSL) return false; // GLSL not available
1233
 
    //    if (!_noshader) return true;
1234
 
 
1235
1038
    GLint loc = GetUniformLocationARB (varname);
1236
1039
 
1237
1040
    if (loc == -1) return false; // can't find variable
1242
1045
  }
1243
1046
  bool IOpenGLShaderProgram::SetUniformLocMatrix4fv (GLint loc, GLsizei count, GLboolean transpose, GLfloat *value)
1244
1047
  {
1245
 
    //    if (!useGLSL) return false; // GLSL not available
1246
 
    //    if (!_noshader) return true;
1247
 
 
1248
1048
    if (loc == -1) return false; // can't find variable
1249
1049
 
1250
1050
    glUniformMatrix4fvARB (loc, count, transpose, value);
1252
1052
    return true;
1253
1053
  }
1254
1054
 
1255
 
//-----------------------------------------------------------------------------
1256
1055
 
1257
1056
  void IOpenGLShaderProgram::GetUniformfv (char *name, GLfloat *values)
1258
1057
  {
1259
 
    //     if (!useGLSL) return;
1260
1058
    GLint loc;
1261
1059
 
1262
1060
    loc = glGetUniformLocationARB (_OpenGLID, name);
1270
1068
    CHECKGL ( glGetUniformfvARB (_OpenGLID, loc, values) );
1271
1069
  }
1272
1070
 
1273
 
//-----------------------------------------------------------------------------
1274
1071
 
1275
1072
  void IOpenGLShaderProgram::GetUniformiv (char *name, GLint *values)
1276
1073
  {
1277
 
    //if (!useGLSL) return;
1278
1074
    GLint loc;
1279
1075
    loc = glGetUniformLocationARB (_OpenGLID, name);
1280
1076
    CHECKGL_MSG ( glGetUniformLocationARB );
1286
1082
 
1287
1083
    CHECKGL ( glGetUniformivARB (_OpenGLID, loc, values) );
1288
1084
  }
1289
 
//-----------------------------------------------------------------------------
1290
1085
 
1291
1086
  int IOpenGLShaderProgram::GetUniformLocationARB (const GLcharARB *name)
1292
1087
  {
1296
1091
    return loc;
1297
1092
  }
1298
1093
 
1299
 
//-----------------------------------------------------------------------------
1300
1094
  void IOpenGLShaderProgram::GetActiveUniformARB (
1301
1095
    GLuint index,
1302
1096
    GLsizei maxLength,
1316
1110
    CHECKGL_MSG (glGetActiveUniformARB);
1317
1111
  }
1318
1112
 
1319
 
//-----------------------------------------------------------------------------
1320
1113
 
1321
1114
  void IOpenGLShaderProgram::GetObjectParameterfvARB (GLenum pname,
1322
1115
      GLfloat *params)
1327
1120
    CHECKGL_MSG (glGetObjectParameterfvARB);
1328
1121
  }
1329
1122
 
1330
 
//-----------------------------------------------------------------------------
1331
 
 
1332
 
  BOOL IOpenGLShaderProgram::SetSampler (char *name, int texture_unit)
 
1123
  bool IOpenGLShaderProgram::SetSampler (char *name, int texture_unit)
1333
1124
  {
1334
1125
    GLint loc = GetUniformLocationARB (name);
1335
1126