diff -r 590c7f324292 -r 07a267d72fce hedgewars/uRender.pas --- a/hedgewars/uRender.pas Fri Jan 05 22:32:11 2018 +0100 +++ b/hedgewars/uRender.pas Sat Jan 06 03:05:14 2018 +0100 @@ -123,9 +123,8 @@ var VertexBuffer : array [0 ..59] of TVertex2f; TextureBuffer: array [0 .. 7] of TVertex2f; LastTint: LongWord = 0; +{$IFNDEF GL2} LastColorPointer , LastTexCoordPointer , LastVertexPointer : Pointer; -{$IFDEF GL2} - LastColorPointerN, LastTexCoordPointerN, LastVertexPointerN: Integer; {$ENDIF} {$IFDEF USE_S3D_RENDERING} @@ -284,6 +283,7 @@ checkFails(f <> nil, 'Unable to load ' + shaderFile, true); source:=''; + line:=''; while not pfsEof(f) do begin pfsReadLnA(f, line); @@ -296,6 +296,7 @@ sourceA:=PChar(source); lengthA:=Length(source); + WriteLnToConsole('Length: ' + inttostr(Length(source))); shader:=glCreateShader(shaderType); glShaderSource(shader, 1, @sourceA, @lengthA); @@ -740,8 +741,8 @@ {$ELSE} glDisableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_COLOR_ARRAY); + LastTexCoordPointer:= nil; {$ENDIF} - LastTexCoordPointer:= nil; end else begin @@ -751,8 +752,8 @@ {$ELSE} glDisableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); + LastColorPointer:= nil; {$ENDIF} - LastColorPointer:= nil; end; EnableTexture(not b); end; @@ -775,58 +776,49 @@ procedure SetTexCoordPointer(p: Pointer; n: Integer); inline; begin {$IFDEF GL2} - if (p = LastTexCoordPointer) and (n = LastTexCoordPointerN) then - exit; glBindBuffer(GL_ARRAY_BUFFER, tBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW); glEnableVertexAttribArray(aTexCoord); glVertexAttribPointer(aTexCoord, 2, GL_FLOAT, GL_FALSE, 0, pointer(0)); - LastTexCoordPointerN:= n; {$ELSE} if p = LastTexCoordPointer then exit; n:= n; glTexCoordPointer(2, GL_FLOAT, 0, p); + LastTexCoordPointer:= p; {$ENDIF} - LastTexCoordPointer:= p; end; procedure SetVertexPointer(p: Pointer; n: Integer); inline; begin {$IFDEF GL2} - if (p = LastVertexPointer) and (n = LastVertexPointerN) then - exit; glBindBuffer(GL_ARRAY_BUFFER, vBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * n * 2, p, GL_STATIC_DRAW); glEnableVertexAttribArray(aVertex); glVertexAttribPointer(aVertex, 2, GL_FLOAT, GL_FALSE, 0, pointer(0)); - LastVertexPointerN:= n; {$ELSE} if p = LastVertexPointer then exit; n:= n; glVertexPointer(2, GL_FLOAT, 0, p); + LastVertexPointer:= p; {$ENDIF} - LastVertexPointer:= p; end; procedure SetColorPointer(p: Pointer; n: Integer); inline; begin {$IFDEF GL2} - if (p = LastColorPointer) and (n = LastColorPointerN) then - exit; glBindBuffer(GL_ARRAY_BUFFER, cBuffer); glBufferData(GL_ARRAY_BUFFER, n * 4, p, GL_STATIC_DRAW); glEnableVertexAttribArray(aColor); glVertexAttribPointer(aColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, pointer(0)); - LastColorPointerN:= n; {$ELSE} if p = LastColorPointer then exit; n:= n; glColorPointer(4, GL_UNSIGNED_BYTE, 0, p); + LastColorPointer:= p; {$ENDIF} - LastColorPointer:= p; end; procedure EnableTexture(enable:Boolean); @@ -883,7 +875,10 @@ end else begin - openglPushMatrix; // save default scaling in matrix + if cScaleFactor = cDefaultZoomLevel then + begin + openglPushMatrix; // save default scaling in matrix; + end; openglLoadIdentity(); openglScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); openglTranslatef(0, -cScreenHeight div 2, 0); @@ -979,7 +974,6 @@ procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); begin - openglPushMatrix; openglTranslatef(X, Y, 0); @@ -996,6 +990,7 @@ glDrawArrays(GL_TRIANGLE_FAN, 0, Length(Texture^.vb)); openglPopMatrix; +UpdateModelviewProjection; end; { this contains tweaks in order to avoid land tile borders in blurry land mode } @@ -1025,6 +1020,8 @@ glDrawArrays(GL_TRIANGLE_FAN, 0, 4); openglPopMatrix; + +UpdateModelviewProjection; end; procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); @@ -1132,6 +1129,8 @@ openglPopMatrix; +UpdateModelviewProjection; + end; procedure DrawSpriteRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); @@ -1171,10 +1170,14 @@ if Angle <> 0 then openglRotatef(Angle, 0, 0, 1); +UpdateModelviewProjection; + DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); openglPopMatrix; +UpdateModelviewProjection; + end; procedure DrawSpritePivotedF(Sprite: TSprite; X, Y, Frame, Dir, PivotX, PivotY: LongInt; Angle: real); @@ -1212,6 +1215,8 @@ DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Height div 2, Frame); openglPopMatrix; + +UpdateModelviewProjection; end; procedure DrawTextureRotated(Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); @@ -1259,6 +1264,7 @@ openglPopMatrix; +UpdateModelviewProjection; end; procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); @@ -1342,6 +1348,8 @@ DrawLineOnScreen(X0, Y0, X1, Y1, Width, r, g, b, a); openglPopMatrix(); + + UpdateModelviewProjection; end; procedure DrawLineOnScreen(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); @@ -1376,7 +1384,6 @@ exit; EnableTexture(False); - Tint(r, g, b, a); with rect do @@ -1510,6 +1517,8 @@ glDrawArrays(GL_TRIANGLE_FAN, 0, 4); openglPopMatrix; + + UpdateModelviewProjection; end; procedure DrawScreenWidget(widget: POnScreenWidget); @@ -1904,8 +1913,6 @@ SetVertexPointer(@VertexBuffer[0], 8); SetTexCoordPointer(@TextureBuffer[0], 8); -UpdateModelviewProjection; - glDrawArrays(GL_TRIANGLE_STRIP, first, count); untint; @@ -2008,13 +2015,10 @@ procedure initModule; begin LastTint:= cWhiteColor + 1; +{$IFNDEF GL2} LastColorPointer := nil; LastTexCoordPointer := nil; LastVertexPointer := nil; -{$IFDEF GL2} - LastColorPointerN := 0; - LastTexCoordPointerN:= 0; - LastVertexPointerN := 0; {$ENDIF} end;