Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultWindowResources is undocumented #49

Closed
OlegAlexander opened this issue Apr 9, 2024 · 3 comments
Closed

defaultWindowResources is undocumented #49

OlegAlexander opened this issue Apr 9, 2024 · 3 comments

Comments

@OlegAlexander
Copy link

OlegAlexander commented Apr 9, 2024

Hello and thank you for creating these bindings!

I wanted to report that the defaultWindowResources function defined here isn't visible in the documentation. I had to click on Source for WindowResources and that's how I found it.

On a related note, I'm trying to get loadTexture to work which requires WindowResources. Would you happen to have an example of using loadTexture? Thanks!

@OlegAlexander
Copy link
Author

Ah, I can see in the DOCUMENTATION.md file that the initWindow function returns a WindowResources. (The DOCUMENTATION.md file is a little hard to find, so that's why I missed it.)

However, my question about an example of using loadTexture still stands. Thanks!

@Anut-py
Copy link
Owner

Anut-py commented Apr 10, 2024

You can look at the examples to see how to use WindowResources. Below is an example of how to use it with loadTexture.

{-# OPTIONS -Wall #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where

import Raylib.Core
import Raylib.Core.Textures
import Raylib.Types
import Raylib.Util
import Raylib.Util.Colors

startup :: IO (WindowResources, Texture)
startup = do
  window <- initWindow 600 450 "loadTexture example"
  setTargetFPS 60
  texture <- loadTexture "/path/to/file" window -- this is what you're looking for
  return (window, texture)

mainLoop :: (WindowResources, Texture) -> IO (WindowResources, Texture)
mainLoop (window, texture) = do
  drawing $ do
      clearBackground rayWhite
      -- use the texture here
  return (window, texture)

shouldClose :: (WindowResources, Texture) -> IO Bool
shouldClose _ = windowShouldClose

teardown :: (WindowResources, Texture) -> IO ()
teardown = closeWindow . fst

raylibApplication 'startup 'mainLoop 'shouldClose 'teardown

@OlegAlexander
Copy link
Author

Thank you! That's super helpful!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants