Fixed 4x resolution scaling for better performances
This commit is contained in:
parent
ef80c7d091
commit
33f7a62c0f
@ -33,9 +33,8 @@ TEXTURE_SIZE = 64
|
|||||||
# Raycast cfg
|
# Raycast cfg
|
||||||
RAYCAST_WIN_WIDTH = 600
|
RAYCAST_WIN_WIDTH = 600
|
||||||
RAYCAST_WIN_HEIGHT = 600
|
RAYCAST_WIN_HEIGHT = 600
|
||||||
RAYCAST_RESOLUTION_SCALING = 4
|
RAYCAST_RENDER_WIDTH = int(RAYCAST_WIN_WIDTH / 4)
|
||||||
RAYCAST_RENDER_WIDTH = int(RAYCAST_WIN_WIDTH / RAYCAST_RESOLUTION_SCALING)
|
RAYCAST_RENDER_HEIGHT = int(RAYCAST_WIN_HEIGHT / 4)
|
||||||
RAYCAST_RENDER_HEIGHT = int(RAYCAST_WIN_HEIGHT / RAYCAST_RESOLUTION_SCALING)
|
|
||||||
DOF = 2*MAP_SIZE # Depth Of Field
|
DOF = 2*MAP_SIZE # Depth Of Field
|
||||||
CEILING_COLOR = sdl2.ext.Color(0,128,255,255)
|
CEILING_COLOR = sdl2.ext.Color(0,128,255,255)
|
||||||
FLOOR_COLOR = sdl2.ext.Color(64,64,64,255)
|
FLOOR_COLOR = sdl2.ext.Color(64,64,64,255)
|
||||||
@ -377,23 +376,13 @@ class Main:
|
|||||||
if lineEnd < lineStart:
|
if lineEnd < lineStart:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Upscaling
|
# Draw segment (all is scaled x4)
|
||||||
lineStart = lineStart * RAYCAST_RESOLUTION_SCALING
|
x = i * 4
|
||||||
lineEnd = lineEnd * RAYCAST_RESOLUTION_SCALING
|
for idx in range(int(lineStart * 4) * RAYCAST_WIN_WIDTH + x, int(lineEnd * 4) * RAYCAST_WIN_WIDTH + x, RAYCAST_WIN_WIDTH):
|
||||||
|
self.raycast_u32_pixels[idx] = color
|
||||||
# Draw segment
|
self.raycast_u32_pixels[idx + 1] = color
|
||||||
for repeat in range(1, RAYCAST_RESOLUTION_SCALING + 1):
|
self.raycast_u32_pixels[idx + 2] = color
|
||||||
x = i * RAYCAST_RESOLUTION_SCALING + repeat
|
self.raycast_u32_pixels[idx + 3] = color
|
||||||
self.drawVline(self.raycastSurface, color, x, int(lineStart), int(lineEnd))
|
|
||||||
|
|
||||||
def drawVline(self, surface, color, x, startY, endY):
|
|
||||||
if x < 0 or x > RAYCAST_WIN_WIDTH or startY < 0 or endY > RAYCAST_WIN_HEIGHT or endY < startY:
|
|
||||||
print("Trying to write outside bounds: vertical line with x {} from y {} to y {}".format(x, startY, endY))
|
|
||||||
return
|
|
||||||
|
|
||||||
startIdx = startY * RAYCAST_WIN_WIDTH + x
|
|
||||||
for idx in range(startIdx, endY * RAYCAST_WIN_WIDTH + x, RAYCAST_WIN_WIDTH):
|
|
||||||
self.raycast_u32_pixels[idx] = color
|
|
||||||
|
|
||||||
def shade(self, color):
|
def shade(self, color):
|
||||||
# Obtain channels
|
# Obtain channels
|
||||||
|
Loading…
x
Reference in New Issue
Block a user