# HG changeset patch # User sheepluva # Date 1427221503 -3600 # Node ID 570af168cc74854da18b5261a76517c3cbadafce # Parent 5efea59424750782a3c906e1560554e66a7dcc15 rendering tweaks cont. diff -r 5efea5942475 -r 570af168cc74 hedgewars/uRender.pas --- a/hedgewars/uRender.pas Tue Mar 24 16:52:35 2015 +0100 +++ b/hedgewars/uRender.pas Tue Mar 24 19:25:03 2015 +0100 @@ -48,6 +48,7 @@ procedure DrawCircle (X, Y, Radius, Width: LongInt); procedure DrawCircle (X, Y, Radius, Width: LongInt; r, g, b, a: Byte); +procedure DrawCircleFilled (X, Y, Radius: LongInt; r, g, b, a: Byte); procedure DrawLine (X0, Y0, X1, Y1, Width: Single; color: LongWord); inline; procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); @@ -81,6 +82,9 @@ procedure RendererSetup(); procedure RendererCleanup(); +procedure ChangeDepth(rm: TRenderMode; d: GLfloat); +procedure ResetDepth(rm: TRenderMode); + // TODO everything below this should not need a public interface procedure EnableTexture(enable:Boolean); @@ -1394,6 +1398,25 @@ glDisable(GL_LINE_SMOOTH); end; +procedure DrawCircleFilled(X, Y, Radius: LongInt; r, g, b, a: Byte); +var + i: LongInt; +begin + VertexBuffer[0].X := X; + VertexBuffer[0].Y := Y; + + for i := 1 to 19 do begin + VertexBuffer[i].X := X + Radius*cos(i*pi/9); + VertexBuffer[i].Y := Y + Radius*sin(i*pi/9); + end; + + EnableTexture(False); + Tint(r, g, b, a); + SetVertexPointer(@VertexBuffer[0], 20); + glDrawArrays(GL_TRIANGLE_FAN, 0, 20); + Untint(); + EnableTexture(True); +end; procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); const VertexBuffer: array [0..3] of TVertex2f = ( @@ -1886,6 +1909,42 @@ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); end; +procedure ChangeDepth(rm: TRenderMode; d: GLfloat); +var tmp: LongInt; +begin +{$IFNDEF USE_S3D_RENDERING} + rm:= rm; d:= d; tmp:= tmp; // avoid hint +{$ELSE} + d:= d / 5; + if rm = rmDefault then + exit + else if rm = rmLeftEye then + d:= -d; + cStereoDepth:= cStereoDepth + d; + openglTranslProjMatrix(d, 0, 0); + tmp:= round(d / cScaleFactor * cScreenWidth); + ViewLeftX := ViewLeftX - tmp; + ViewRightX:= ViewRightX - tmp; +{$ENDIF} +end; + +procedure ResetDepth(rm: TRenderMode); +var tmp: LongInt; +begin +{$IFNDEF USE_S3D_RENDERING} + rm:= rm; tmp:= tmp; // avoid hint +{$ELSE} + if rm = rmDefault then + exit; + openglTranslProjMatrix(-cStereoDepth, 0, 0); + tmp:= round(cStereoDepth / cScaleFactor * cScreenWidth); + ViewLeftX := ViewLeftX + tmp; + ViewRightX:= ViewRightX + tmp; + cStereoDepth:= 0; +{$ENDIF} +end; + + procedure initModule; begin LastTint:= cWhiteColor + 1; diff -r 5efea5942475 -r 570af168cc74 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Tue Mar 24 16:52:35 2015 +0100 +++ b/hedgewars/uWorld.pas Tue Mar 24 19:25:03 2015 +0100 @@ -17,7 +17,6 @@ *) {$INCLUDE "options.inc"} -{$IF GLunit = GL}{$DEFINE GLunit:=GL}{$ENDIF} unit uWorld; interface @@ -53,7 +52,6 @@ , uVisualGears , uChat , uLandTexture - , GLunit , uVariables , uUtils , uTextures @@ -881,41 +879,6 @@ FinishRender(); end; -procedure ChangeDepth(rm: TRenderMode; d: GLfloat); -var tmp: LongInt; -begin -{$IFNDEF USE_S3D_RENDERING} - rm:= rm; d:= d; tmp:= tmp; // avoid hint -{$ELSE} - d:= d / 5; - if rm = rmDefault then - exit - else if rm = rmLeftEye then - d:= -d; - cStereoDepth:= cStereoDepth + d; - openglTranslProjMatrix(d, 0, 0); - tmp:= round(d / cScaleFactor * cScreenWidth); - ViewLeftX := ViewLeftX - tmp; - ViewRightX:= ViewRightX - tmp; -{$ENDIF} -end; - -procedure ResetDepth(rm: TRenderMode); -var tmp: LongInt; -begin -{$IFNDEF USE_S3D_RENDERING} - rm:= rm; tmp:= tmp; // avoid hint -{$ELSE} - if rm = rmDefault then - exit; - openglTranslProjMatrix(-cStereoDepth, 0, 0); - tmp:= round(cStereoDepth / cScaleFactor * cScreenWidth); - ViewLeftX := ViewLeftX + tmp; - ViewRightX:= ViewRightX + tmp; - cStereoDepth:= 0; -{$ENDIF} -end; - procedure RenderWorldEdge; var //VertexBuffer: array [0..3] of TVertex2f; @@ -1200,8 +1163,8 @@ tdx, tdy: Double; s: shortstring; offsetX, offsetY, screenBottom: LongInt; - VertexBuffer: array [0..3] of TVertex2f; replicateToLeft, replicateToRight, tmp: boolean; + a: Byte; begin if WorldEdge <> weWrap then begin @@ -1632,27 +1595,16 @@ end; if ScreenFade <> sfNone then begin + r.x:= ViewLeftX; + r.y:= ViewTopY; + r.w:= ViewWidth; + r.h:= ViewHeight; + case ScreenFade of - sfToBlack, sfFromBlack: Tint(0, 0, 0, ScreenFadeValue * 255 div 1000); - sfToWhite, sfFromWhite: Tint($FF, $FF, $FF, ScreenFadeValue * 255 div 1000); + sfToBlack, sfFromBlack: DrawRect(r, 0, 0, 0, ScreenFadeValue * 255 div 1000, true); + sfToWhite, sfFromWhite: DrawRect(r, $FF, $FF, $FF, ScreenFadeValue * 255 div 1000, true); end; - VertexBuffer[0].X:= -cScreenWidth; - VertexBuffer[0].Y:= cScreenHeight; - VertexBuffer[1].X:= -cScreenWidth; - VertexBuffer[1].Y:= 0; - VertexBuffer[2].X:= cScreenWidth; - VertexBuffer[2].Y:= 0; - VertexBuffer[3].X:= cScreenWidth; - VertexBuffer[3].Y:= cScreenHeight; - - EnableTexture(false); - - SetVertexPointer(@VertexBuffer[0], 4); - glDrawArrays(GL_TRIANGLE_FAN, 0, High(VertexBuffer) - Low(VertexBuffer) + 1); - - EnableTexture(true); - untint; if not isFirstFrame and ((ScreenFadeValue = 0) or (ScreenFadeValue = sfMax)) then ScreenFade:= sfNone end @@ -1673,15 +1625,11 @@ end; DrawTexture( -(cScreenWidth shr 1) + 50, 20, recTexture); + //a:= Byte(Round(127*(1 + sin(RealTicks*0.007)))); + a:= Byte(min(255, abs(-255 + ((RealTicks div 2) and 511)))); + // draw red circle - glDisable(GL_TEXTURE_2D); - Tint($FF, $00, $00, Byte(Round(127*(1 + sin(SDL_GetTicks()*0.007))))); - glBegin(GL_POLYGON); - for i:= 0 to 20 do - glVertex2f(-(cScreenWidth shr 1) + 30 + sin(i*2*Pi/20)*10, 35 + cos(i*2*Pi/20)*10); - glEnd(); - untint; - glEnable(GL_TEXTURE_2D); + DrawCircleFilled(-(cScreenWidth shr 1) + 30, 35, 10, $FF, $00, $00, a); end; {$ENDIF}