<commit_before>module Main where

import qualified LilRender.Color.Named as NC
import LilRender.Image
import LilRender.Model
import LilRender.Renderer
import LilRender.Shader.Library
import LilRender.Texture
import LilRender.Math.Geometry
import LilRender.Math.Vector
import LilRender.Math.Transform

width = 800
height = 800

lightDirection = World (Vector3 1.0 1.0 1.0)

center :: Int -> Int -> Screen (Point2 Int)
center width height = Screen (Point2 x y)
    where
        x = round ((fromIntegral width) / 8)
        y = round ((fromIntegral height) / 8)

scale' :: Double -> (Int -> Int)
scale' factor a = a'
    where a' = round ((fromIntegral a) * factor)

main :: IO ()
main = do
    model <- loadModel WavefrontOBJ "data/african_head/african_head.obj"
    texture <- loadTexture TGA "data/african_head/african_head_diffuse.tga"

    let cameraLocation = World (Point3 1.0 1.0 3.0)
    let cameraTarget   = World (Point3 0.0 0.0 0.0)
    let camera = cameraTransform cameraLocation cameraTarget

    let scale = scale' (3/4)
    let viewport = viewportTransform (center width height) (scale width) (scale height)

    let modelToScreen = (identityTransform :: Transform (ModelSpace (Point3 Double)) (World (Point3 Double))) >>> camera >>> orthographicProjectionTransform >>> viewport

    shader <- gouraudShader lightDirection identityTransform
    image <- drawImageWith width height NC.black (\image -> drawTexturedModel image model texture shader modelToScreen)
    saveImage TGA "head.tga" image
<commit_msg>Give a rough estimate of how I’m doing.<commit_after>module Main where

import qualified LilRender.Color.Named as NC
import LilRender.Image
import LilRender.Model
import LilRender.Renderer
import LilRender.Shader.Library
import LilRender.Texture
import LilRender.Math.Geometry
import LilRender.Math.Vector
import LilRender.Math.Transform

import           Criterion.Measurement           (getTime, initializeTime, secs)

width = 800
height = 800

lightDirection = World (Vector3 1.0 1.0 1.0)

center :: Int -> Int -> Screen (Point2 Int)
center width height = Screen (Point2 x y)
    where
        x = round ((fromIntegral width) / 8)
        y = round ((fromIntegral height) / 8)

scale' :: Double -> (Int -> Int)
scale' factor a = a'
    where a' = round ((fromIntegral a) * factor)

main :: IO ()
main = do
    model <- loadModel WavefrontOBJ "data/african_head/african_head.obj"
    texture <- loadTexture TGA "data/african_head/african_head_diffuse.tga"

    let cameraLocation = World (Point3 1.0 1.0 3.0)
    let cameraTarget   = World (Point3 0.0 0.0 0.0)
    let camera = cameraTransform cameraLocation cameraTarget

    let scale = scale' (3/4)
    let viewport = viewportTransform (center width height) (scale width) (scale height)

    let modelToScreen = (identityTransform :: Transform (ModelSpace (Point3 Double)) (World (Point3 Double))) >>> camera >>> orthographicProjectionTransform >>> viewport

    shader <- gouraudShader lightDirection identityTransform

    initializeTime

    startTime <- getTime
    image <- drawImageWith width height NC.black (\image -> drawTexturedModel image model texture shader modelToScreen)
    endTime <- getTime

    putStrLn $ "Frame time: " ++ secs (endTime - startTime)

    saveImage TGA "head.tga" image

{'fraction_non_alphanumeric': 0.09503502893694792, 'fraction_numerical': 0.021321961620469083, 'mean_word_length': 3.7319884726224783, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7604250', 'n_tokens_mistral': 1021, 'n_tokens_neox': 947, 'n_words': 323}