-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHello.hs
49 lines (45 loc) · 1.46 KB
/
Hello.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import BGFX
import Data.Bits
import Foreign.Ptr
import qualified SDL
import Unsafe.Coerce
foreign import ccall unsafe
"bgfx_sdl_set_window" bgfxSdlSetWindow :: Ptr a -> IO ()
main :: IO ()
main = do
let width = 1280
let height = 720
let debug = BGFX_DEBUG_TEXT
let reset = BGFX_RESET_VSYNC
SDL.initializeAll
w <- SDL.createWindow "bgfx with SDL2" SDL.defaultWindow
bgfxSdlSetWindow (unsafeCoerce w :: Ptr ())
bgfxRenderFrame
bgfxInit BGFX_RENDERER_TYPE_COUNT BGFX_PCI_ID_NONE 0 nullPtr nullPtr
putStrLn "A"
bgfxReset width height reset
bgfxSetDebug debug
bgfxSetViewClear 0 (BGFX_CLEAR_COLOR .|. BGFX_CLEAR_DEPTH) 0x303030ff 1.0 0
let loop = do
--done <- _processEvents width height debug reset
done <- return False
if done then return () else do { tick ; loop }
tick = do
bgfxSetViewRect 0 0 0 (fromIntegral width) (fromIntegral height)
bgfxTouch 0
-- bgfxDbgTextClear
-- bgfx::dbgTextImage(bx::uint16_max(width/2/8, 20)-20
-- , bx::uint16_max(height/2/16, 6)-6
-- , 40
-- , 12
-- , s_logo
-- , 160
-- );
-- bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
-- bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
bgfxFrame
loop
bgfxShutdown