hedgewars/uRender.pas
branchios-develop
changeset 13418 ba39a1d396c0
parent 12903 8a40ce061d94
child 13500 b5f8864a38d3
equal deleted inserted replaced
13416:6e8b807bda4b 13418:ba39a1d396c0
    66 {$ENDIF}
    66 {$ENDIF}
    67 procedure RenderSetClearColor   (r, g, b, a: real);
    67 procedure RenderSetClearColor   (r, g, b, a: real);
    68 procedure Tint                  (r, g, b, a: Byte); inline;
    68 procedure Tint                  (r, g, b, a: Byte); inline;
    69 procedure Tint                  (c: Longword); inline;
    69 procedure Tint                  (c: Longword); inline;
    70 procedure untint(); inline;
    70 procedure untint(); inline;
    71 procedure setTintAdd            (f: boolean); inline;
    71 procedure setTintAdd            (enable: boolean); inline;
    72 
    72 
    73 // call this to finish the rendering of current frame
    73 // call this to finish the rendering of current frame
    74 procedure FinishRender();
    74 procedure FinishRender();
    75 
    75 
    76 function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline;
    76 function isAreaOffscreen(X, Y, Width, Height: LongInt): boolean; inline;
   104 procedure openglTranslatef      (X, Y, Z: GLfloat); inline;
   104 procedure openglTranslatef      (X, Y, Z: GLfloat); inline;
   105 
   105 
   106 
   106 
   107 implementation
   107 implementation
   108 uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}uVariables, uUtils
   108 uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}uVariables, uUtils
   109      {$IFDEF GL2}, uMatrix, uConsole{$ENDIF}, uConsts;
   109      {$IFDEF GL2}, uMatrix, uConsole, uPhysFSLayer, uDebug{$ENDIF}, uConsts;
   110 
   110 
   111 {$IFDEF USE_TOUCH_INTERFACE}
   111 {$IFDEF USE_TOUCH_INTERFACE}
   112 const
   112 const
   113     FADE_ANIM_TIME = 500;
   113     FADE_ANIM_TIME = 500;
   114     MOVE_ANIM_TIME = 500;
   114     MOVE_ANIM_TIME = 500;
   121 {$ENDIF}
   121 {$ENDIF}
   122 
   122 
   123 var VertexBuffer : array [0 ..59] of TVertex2f;
   123 var VertexBuffer : array [0 ..59] of TVertex2f;
   124     TextureBuffer: array [0 .. 7] of TVertex2f;
   124     TextureBuffer: array [0 .. 7] of TVertex2f;
   125     LastTint: LongWord = 0;
   125     LastTint: LongWord = 0;
       
   126 {$IFNDEF GL2}
   126     LastColorPointer , LastTexCoordPointer , LastVertexPointer : Pointer;
   127     LastColorPointer , LastTexCoordPointer , LastVertexPointer : Pointer;
   127 {$IFDEF GL2}
       
   128     LastColorPointerN, LastTexCoordPointerN, LastVertexPointerN: Integer;
       
   129 {$ENDIF}
   128 {$ENDIF}
   130 
   129 
   131 {$IFDEF USE_S3D_RENDERING}
   130 {$IFDEF USE_S3D_RENDERING}
   132     // texture/vertex buffers for left/right/default eye modes
   131     // texture/vertex buffers for left/right/default eye modes
   133     texLRDtb, texLvb, texRvb: array [0..3] of TVertex2f;
   132     texLRDtb, texLvb, texRvb: array [0..3] of TVertex2f;
   738         glDisableVertexAttribArray(aTexCoord);
   737         glDisableVertexAttribArray(aTexCoord);
   739         glEnableVertexAttribArray(aColor);
   738         glEnableVertexAttribArray(aColor);
   740         {$ELSE}
   739         {$ELSE}
   741         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
   740         glDisableClientState(GL_TEXTURE_COORD_ARRAY);
   742         glEnableClientState(GL_COLOR_ARRAY);
   741         glEnableClientState(GL_COLOR_ARRAY);
       
   742         LastTexCoordPointer:= nil;
   743         {$ENDIF}
   743         {$ENDIF}
   744         LastTexCoordPointer:= nil;
       
   745         end
   744         end
   746     else
   745     else
   747         begin
   746         begin
   748         {$IFDEF GL2}
   747         {$IFDEF GL2}
   749         glDisableVertexAttribArray(aColor);
   748         glDisableVertexAttribArray(aColor);
   750         glEnableVertexAttribArray(aTexCoord);
   749         glEnableVertexAttribArray(aTexCoord);
   751         {$ELSE}
   750         {$ELSE}
   752         glDisableClientState(GL_COLOR_ARRAY);
   751         glDisableClientState(GL_COLOR_ARRAY);
   753         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
   752         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
       
   753         LastColorPointer:= nil;
   754         {$ENDIF}
   754         {$ENDIF}
   755         LastColorPointer:= nil;
       
   756         end;
   755         end;
   757     EnableTexture(not b);
   756     EnableTexture(not b);
   758 end;
   757 end;
   759 
   758 
   760 procedure UpdateModelviewProjection(); inline;
   759 procedure UpdateModelviewProjection(); inline;
   773 end;
   772 end;
   774 
   773 
   775 procedure SetTexCoordPointer(p: Pointer; n: Integer); inline;
   774 procedure SetTexCoordPointer(p: Pointer; n: Integer); inline;
   776 begin
   775 begin
   777 {$IFDEF GL2}
   776 {$IFDEF GL2}
   778     if (p = LastTexCoordPointer) and (n = LastTexCoordPointerN) then
       
   779         exit;
       
   780     glBindBuffer(GL_ARRAY_BUFFER, tBuffer);
   777     glBindBuffer(GL_ARRAY_BUFFER, tBuffer);
   781     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
   778     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
   782     glEnableVertexAttribArray(aTexCoord);
   779     glEnableVertexAttribArray(aTexCoord);
   783     glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
   780     glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
   784     LastTexCoordPointerN:= n;
       
   785 {$ELSE}
   781 {$ELSE}
   786     if p = LastTexCoordPointer then
   782     if p = LastTexCoordPointer then
   787         exit;
   783         exit;
   788     n:= n;
   784     n:= n;
   789     glTexCoordPointer(2, GL_FLOAT, 0, p);
   785     glTexCoordPointer(2, GL_FLOAT, 0, p);
   790 {$ENDIF}
       
   791     LastTexCoordPointer:= p;
   786     LastTexCoordPointer:= p;
       
   787 {$ENDIF}
   792 end;
   788 end;
   793 
   789 
   794 procedure SetVertexPointer(p: Pointer; n: Integer); inline;
   790 procedure SetVertexPointer(p: Pointer; n: Integer); inline;
   795 begin
   791 begin
   796 {$IFDEF GL2}
   792 {$IFDEF GL2}
   797     if (p = LastVertexPointer) and (n = LastVertexPointerN) then
       
   798         exit;
       
   799     glBindBuffer(GL_ARRAY_BUFFER, vBuffer);
   793     glBindBuffer(GL_ARRAY_BUFFER, vBuffer);
   800     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
   794     glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW);
   801     glEnableVertexAttribArray(aVertex);
   795     glEnableVertexAttribArray(aVertex);
   802     glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
   796     glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0));
   803     LastVertexPointerN:= n;
       
   804 {$ELSE}
   797 {$ELSE}
   805     if p = LastVertexPointer then
   798     if p = LastVertexPointer then
   806         exit;
   799         exit;
   807     n:= n;
   800     n:= n;
   808     glVertexPointer(2, GL_FLOAT, 0, p);
   801     glVertexPointer(2, GL_FLOAT, 0, p);
   809 {$ENDIF}
       
   810     LastVertexPointer:= p;
   802     LastVertexPointer:= p;
       
   803 {$ENDIF}
   811 end;
   804 end;
   812 
   805 
   813 procedure SetColorPointer(p: Pointer; n: Integer); inline;
   806 procedure SetColorPointer(p: Pointer; n: Integer); inline;
   814 begin
   807 begin
   815 {$IFDEF GL2}
   808 {$IFDEF GL2}
   816     if (p = LastColorPointer) and (n = LastColorPointerN) then
       
   817         exit;
       
   818     glBindBuffer(GL_ARRAY_BUFFER, cBuffer);
   809     glBindBuffer(GL_ARRAY_BUFFER, cBuffer);
   819     glBufferData(GL_ARRAY_BUFFER, n * 4, p, GL_STATIC_DRAW);
   810     glBufferData(GL_ARRAY_BUFFER, n * 4, p, GL_STATIC_DRAW);
   820     glEnableVertexAttribArray(aColor);
   811     glEnableVertexAttribArray(aColor);
   821     glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0));
   812     glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0));
   822     LastColorPointerN:= n;
       
   823 {$ELSE}
   813 {$ELSE}
   824     if p = LastColorPointer then
   814     if p = LastColorPointer then
   825         exit;
   815         exit;
   826     n:= n;
   816     n:= n;
   827     glColorPointer(4, GL_UNSIGNED_BYTE, 0, p);
   817     glColorPointer(4, GL_UNSIGNED_BYTE, 0, p);
   828 {$ENDIF}
       
   829     LastColorPointer:= p;
   818     LastColorPointer:= p;
       
   819 {$ENDIF}
   830 end;
   820 end;
   831 
   821 
   832 procedure EnableTexture(enable:Boolean);
   822 procedure EnableTexture(enable:Boolean);
   833 begin
   823 begin
   834     {$IFDEF GL2}
   824     {$IFDEF GL2}
   881         begin
   871         begin
   882         openglPopMatrix;
   872         openglPopMatrix;
   883         end
   873         end
   884     else
   874     else
   885         begin
   875         begin
   886         openglPushMatrix; // save default scaling in matrix
   876         if cScaleFactor = cDefaultZoomLevel then
       
   877             begin
       
   878             openglPushMatrix; // save default scaling in matrix;
       
   879             end;
   887         openglLoadIdentity();
   880         openglLoadIdentity();
   888         openglScalef(f / cScreenWidth, -f / cScreenHeight, 1.0);
   881         openglScalef(f / cScreenWidth, -f / cScreenHeight, 1.0);
   889         openglTranslatef(0, -cScreenHeight div 2, 0);
   882         openglTranslatef(0, -cScreenHeight div 2, 0);
   890         end;
   883         end;
   891 
   884 
   942     end;
   935     end;
   943 
   936 
   944 _t:= r^.y / SourceTexture^.h * SourceTexture^.ry;
   937 _t:= r^.y / SourceTexture^.h * SourceTexture^.ry;
   945 _b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry;
   938 _b:= (r^.y + r^.h) / SourceTexture^.h * SourceTexture^.ry;
   946 
   939 
   947 glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
       
   948 
   940 
   949 xw:= X + W;
   941 xw:= X + W;
   950 yh:= Y + H;
   942 yh:= Y + H;
   951 
   943 
   952 VertexBuffer[0].X:= X;
   944 VertexBuffer[0].X:= X;
   965 TextureBuffer[2].X:= _r;
   957 TextureBuffer[2].X:= _r;
   966 TextureBuffer[2].Y:= _b;
   958 TextureBuffer[2].Y:= _b;
   967 TextureBuffer[3].X:= _l;
   959 TextureBuffer[3].X:= _l;
   968 TextureBuffer[3].Y:= _b;
   960 TextureBuffer[3].Y:= _b;
   969 
   961 
       
   962 
       
   963 glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
   970 SetVertexPointer(@VertexBuffer[0], 4);
   964 SetVertexPointer(@VertexBuffer[0], 4);
   971 SetTexCoordPointer(@TextureBuffer[0], 4);
   965 SetTexCoordPointer(@TextureBuffer[0], 4);
       
   966 
   972 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
   967 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
       
   968 
   973 end;
   969 end;
   974 
   970 
   975 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); inline;
   971 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); inline;
   976 begin
   972 begin
   977     DrawTexture(X, Y, Texture, 1.0);
   973     DrawTexture(X, Y, Texture, 1.0);
   978 end;
   974 end;
   979 
   975 
   980 procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
   976 procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat);
   981 begin
   977 begin
   982 
       
   983 openglPushMatrix;
   978 openglPushMatrix;
   984 openglTranslatef(X, Y, 0);
   979 openglTranslatef(X, Y, 0);
   985 
   980 
   986 if Scale <> 1.0 then
   981 if Scale <> 1.0 then
   987     openglScalef(Scale, Scale, 1);
   982     openglScalef(Scale, Scale, 1);
   994 UpdateModelviewProjection;
   989 UpdateModelviewProjection;
   995 
   990 
   996 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
   991 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb));
   997 openglPopMatrix;
   992 openglPopMatrix;
   998 
   993 
       
   994 UpdateModelviewProjection;
   999 end;
   995 end;
  1000 
   996 
  1001 { this contains tweaks in order to avoid land tile borders in blurry land mode }
   997 { this contains tweaks in order to avoid land tile borders in blurry land mode }
  1002 procedure DrawTexture2(X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
   998 procedure DrawTexture2(X, Y: LongInt; Texture: PTexture; Scale, Overlap: GLfloat);
  1003 var
   999 var
  1023 
  1019 
  1024 UpdateModelviewProjection;
  1020 UpdateModelviewProjection;
  1025 
  1021 
  1026 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1022 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1027 openglPopMatrix;
  1023 openglPopMatrix;
       
  1024 
       
  1025 UpdateModelviewProjection;
  1028 end;
  1026 end;
  1029 
  1027 
  1030 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
  1028 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt);
  1031 begin
  1029 begin
  1032     DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0)
  1030     DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0)
  1130 
  1128 
  1131 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1129 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1132 
  1130 
  1133 openglPopMatrix;
  1131 openglPopMatrix;
  1134 
  1132 
       
  1133 UpdateModelviewProjection;
       
  1134 
  1135 end;
  1135 end;
  1136 
  1136 
  1137 procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
  1137 procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
  1138 begin
  1138 begin
  1139     DrawTextureRotated(SpritesData[Sprite].Texture,
  1139     DrawTextureRotated(SpritesData[Sprite].Texture,
  1146 begin
  1146 begin
  1147 
  1147 
  1148 if Angle <> 0  then
  1148 if Angle <> 0  then
  1149     begin
  1149     begin
  1150     // Check the bounding circle 
  1150     // Check the bounding circle 
  1151     if isCircleOffscreen(X, Y, sqr(SpritesData[Sprite].Width) + sqr(SpritesData[Sprite].Height)) then
  1151     if isCircleOffscreen(X, Y, (sqr(SpritesData[Sprite].Width) + sqr(SpritesData[Sprite].Height)) div 4) then
  1152         exit;
  1152         exit;
  1153     end
  1153     end
  1154 else
  1154 else
  1155     begin
  1155     begin
  1156     if isDxAreaOffscreen(X - SpritesData[Sprite].Width div 2, SpritesData[Sprite].Width) <> 0 then
  1156     if isDxAreaOffscreen(X - SpritesData[Sprite].Width div 2, SpritesData[Sprite].Width) <> 0 then
  1169 
  1169 
  1170 // apply angle after (conditional) mirroring
  1170 // apply angle after (conditional) mirroring
  1171 if Angle <> 0  then
  1171 if Angle <> 0  then
  1172     openglRotatef(Angle, 0, 0, 1);
  1172     openglRotatef(Angle, 0, 0, 1);
  1173 
  1173 
       
  1174 UpdateModelviewProjection;
       
  1175 
  1174 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
  1176 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
  1175 
  1177 
  1176 openglPopMatrix;
  1178 openglPopMatrix;
       
  1179 
       
  1180 UpdateModelviewProjection;
  1177 
  1181 
  1178 end;
  1182 end;
  1179 
  1183 
  1180 procedure DrawSpritePivotedF(Sprite: TSprite; X, Y, Frame, Dir, PivotX, PivotY: LongInt; Angle: real);
  1184 procedure DrawSpritePivotedF(Sprite: TSprite; X, Y, Frame, Dir, PivotX, PivotY: LongInt; Angle: real);
  1181 begin
  1185 begin
  1210     end;
  1214     end;
  1211 
  1215 
  1212 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
  1216 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame);
  1213 
  1217 
  1214 openglPopMatrix;
  1218 openglPopMatrix;
       
  1219 
       
  1220 UpdateModelviewProjection;
  1215 end;
  1221 end;
  1216 
  1222 
  1217 procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
  1223 procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
  1218 begin
  1224 begin
  1219 
  1225 
  1257 
  1263 
  1258 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1264 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1259 
  1265 
  1260 openglPopMatrix;
  1266 openglPopMatrix;
  1261 
  1267 
       
  1268 UpdateModelviewProjection;
  1262 end;
  1269 end;
  1263 
  1270 
  1264 procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt);
  1271 procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt);
  1265 var row, col, numFramesFirstCol: LongInt;
  1272 var row, col, numFramesFirstCol: LongInt;
  1266 begin
  1273 begin
  1340     UpdateModelviewProjection;
  1347     UpdateModelviewProjection;
  1341 
  1348 
  1342     DrawLineOnScreen(X0, Y0, X1, Y1, Width, r, g, b, a);
  1349     DrawLineOnScreen(X0, Y0, X1, Y1, Width, r, g, b, a);
  1343 
  1350 
  1344     openglPopMatrix();
  1351     openglPopMatrix();
       
  1352 
       
  1353     UpdateModelviewProjection;
  1345 end;
  1354 end;
  1346 
  1355 
  1347 procedure DrawLineOnScreen(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
  1356 procedure DrawLineOnScreen(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte);
  1348 begin
  1357 begin
  1349     glEnable(GL_LINE_SMOOTH);
  1358     glEnable(GL_LINE_SMOOTH);
  1374     exit;
  1383     exit;
  1375 if (abs(rect.y) > rect.h) and ((abs(rect.y + rect.h / 2 - (cScreenHeight / 2)) - rect.h / 2) * 2 > ViewHeight) then
  1384 if (abs(rect.y) > rect.h) and ((abs(rect.y + rect.h / 2 - (cScreenHeight / 2)) - rect.h / 2) * 2 > ViewHeight) then
  1376     exit;
  1385     exit;
  1377 
  1386 
  1378 EnableTexture(False);
  1387 EnableTexture(False);
  1379 
       
  1380 Tint(r, g, b, a);
  1388 Tint(r, g, b, a);
  1381 
  1389 
  1382 with rect do
  1390 with rect do
  1383 begin
  1391 begin
  1384     VertexBuffer[0].X:= x;
  1392     VertexBuffer[0].X:= x;
  1508     UpdateModelviewProjection;
  1516     UpdateModelviewProjection;
  1509 
  1517 
  1510     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1518     glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
  1511 
  1519 
  1512     openglPopMatrix;
  1520     openglPopMatrix;
       
  1521 
       
  1522     UpdateModelviewProjection;
  1513 end;
  1523 end;
  1514 
  1524 
  1515 procedure DrawScreenWidget(widget: POnScreenWidget);
  1525 procedure DrawScreenWidget(widget: POnScreenWidget);
  1516 {$IFDEF USE_TOUCH_INTERFACE}
  1526 {$IFDEF USE_TOUCH_INTERFACE}
  1517 var alpha: byte = $FF;
  1527 var alpha: byte = $FF;
  1902 glBindTexture(GL_TEXTURE_2D, SpritesData[sprite].Texture^.id);
  1912 glBindTexture(GL_TEXTURE_2D, SpritesData[sprite].Texture^.id);
  1903 
  1913 
  1904 SetVertexPointer(@VertexBuffer[0], 8);
  1914 SetVertexPointer(@VertexBuffer[0], 8);
  1905 SetTexCoordPointer(@TextureBuffer[0], 8);
  1915 SetTexCoordPointer(@TextureBuffer[0], 8);
  1906 
  1916 
  1907 UpdateModelviewProjection;
       
  1908 
       
  1909 glDrawArrays(GL_TRIANGLE_STRIP, first, count);
  1917 glDrawArrays(GL_TRIANGLE_STRIP, first, count);
  1910 
  1918 
  1911 untint;
  1919 untint;
  1912 
  1920 
  1913 end;
  1921 end;
  1959     if cWhiteColor = LastTint then exit;
  1967     if cWhiteColor = LastTint then exit;
  1960     openglTint($FF, $FF, $FF, $FF);
  1968     openglTint($FF, $FF, $FF, $FF);
  1961     LastTint:= cWhiteColor;
  1969     LastTint:= cWhiteColor;
  1962 end;
  1970 end;
  1963 
  1971 
  1964 procedure setTintAdd(f: boolean); inline;
  1972 procedure setTintAdd(enable: boolean); inline;
  1965 begin
  1973 begin
  1966     if f then
  1974     {$IFDEF GL2}
       
  1975         if enable then
       
  1976             glUniform1i(glGetUniformLocation(shaderMain, pchar('tintAdd')), 1)
       
  1977         else
       
  1978             glUniform1i(glGetUniformLocation(shaderMain, pchar('tintAdd')), 0);
       
  1979     {$ELSE}
       
  1980     if enable then
  1967         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD)
  1981         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD)
  1968     else
  1982     else
  1969         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  1983         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
       
  1984     {$ENDIF}
  1970 end;
  1985 end;
  1971 
  1986 
  1972 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
  1987 procedure ChangeDepth(rm: TRenderMode; d: GLfloat);
  1973 var tmp: LongInt;
  1988 var tmp: LongInt;
  1974 begin
  1989 begin
  2006 
  2021 
  2007 
  2022 
  2008 procedure initModule;
  2023 procedure initModule;
  2009 begin
  2024 begin
  2010     LastTint:= cWhiteColor + 1;
  2025     LastTint:= cWhiteColor + 1;
       
  2026 {$IFNDEF GL2}
  2011     LastColorPointer    := nil;
  2027     LastColorPointer    := nil;
  2012     LastTexCoordPointer := nil;
  2028     LastTexCoordPointer := nil;
  2013     LastVertexPointer   := nil;
  2029     LastVertexPointer   := nil;
  2014 {$IFDEF GL2}
       
  2015     LastColorPointerN   :=   0;
       
  2016     LastTexCoordPointerN:=   0;
       
  2017     LastVertexPointerN  :=   0;
       
  2018 {$ENDIF}
  2030 {$ENDIF}
  2019 end;
  2031 end;
  2020 
  2032 
  2021 procedure freeModule;
  2033 procedure freeModule;
  2022 begin
  2034 begin