changeset 435:065854cdba52

add: default samplers
author Sam <sam@basx.dev>
date Sat, 10 Feb 2024 21:19:43 +0700
parents 30cc1deda4c1
children 36b907544820
files semicongine/core/imagetypes.nim
diffstat 1 files changed, 12 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/core/imagetypes.nim	Sat Feb 10 21:19:31 2024 +0700
+++ b/semicongine/core/imagetypes.nim	Sat Feb 10 21:19:43 2024 +0700
@@ -59,7 +59,7 @@
 
   image[].imagedata[y * image.width + x] = value
 
-proc newImage*[T: Pixel](width, height: int, imagedata: openArray[T]= []): Image[T] =
+proc newImage*[T: Pixel](width, height: int, imagedata: openArray[T] = []): Image[T] =
   assert width > 0 and height > 0
   assert imagedata.len == width * height or imagedata.len == 0
 
@@ -70,17 +70,19 @@
   result.width = width
   result.height = height
 
-let INVALID_TEXTURE* = Texture(name: "Invalid texture", isGrayscale: false, colorImage: newImage(1, 1, @[[255'u8, 0'u8, 255'u8, 255'u8]]), sampler: Sampler(
+const
+  LINEAR_SAMPLER* = Sampler(
+    magnification: VK_FILTER_LINEAR,
+    minification: VK_FILTER_LINEAR,
+    wrapModeS: VK_SAMPLER_ADDRESS_MODE_REPEAT,
+    wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT,
+  )
+  NEAREST_SAMPLER* = Sampler(
     magnification: VK_FILTER_NEAREST,
     minification: VK_FILTER_NEAREST,
     wrapModeS: VK_SAMPLER_ADDRESS_MODE_REPEAT,
     wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT,
   )
-)
-let EMPTY_TEXTURE* = Texture(name: "Empty texture", isGrayscale: false, colorImage: newImage(1, 1, @[[255'u8, 255'u8, 255'u8, 255'u8]]), sampler: Sampler(
-    magnification: VK_FILTER_NEAREST,
-    minification: VK_FILTER_NEAREST,
-    wrapModeS: VK_SAMPLER_ADDRESS_MODE_REPEAT,
-    wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT,
-  )
-)
+let
+  INVALID_TEXTURE* = Texture(name: "Invalid texture", isGrayscale: false, colorImage: newImage(1, 1, @[[255'u8, 0'u8, 255'u8, 255'u8]]), sampler: NEAREST_SAMPLER)
+  EMPTY_TEXTURE* = Texture(name: "Empty texture", isGrayscale: false, colorImage: newImage(1, 1, @[[255'u8, 255'u8, 255'u8, 255'u8]]), sampler: NEAREST_SAMPLER)