[feat] unify with example, actually win for once

This commit is contained in:
mtgmonkey
2025-12-16 00:24:10 +01:00
parent 170685f6c8
commit 5a701a3632
8 changed files with 14166 additions and 34 deletions

View File

@@ -10,7 +10,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
- support for Windows
- support for actually doing anything
- autogen code
## [0.2.0] -- 2025-12-16
### Added
- example exe
### Changed
- probably everything ngl
- use SemVer instead of PVP
### Removed
- probably everything ngl
## [0.1.0.2] -- 2025-12-11

View File

@@ -7,9 +7,11 @@
self,
...
}: let
version = "0.2.0";
package = {
mkDerivation,
base,
bindings-DSL,
gl,
lib,
libGL,
@@ -20,10 +22,11 @@
}:
mkDerivation {
pname = "hs-rgfw";
version = "0.1.0.0";
version = "0.2.0";
src = ./.;
libraryHaskellDepends = [
base
bindings-DSL
];
libraryPkgconfigDepends = [
gl

View File

@@ -1,53 +1,47 @@
cabal-version: 3.0
name: hs-rgfw
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.1.0.2
-- A short (one-line) description of the package.
-- synopsis:
-- A longer description of the package.
-- description:
version: 0.2.0
homepage: https://git.mtgmonkey.net/Andromeda/hs-rgfw
license: BSD-3-Clause
license-file: LICENSE
author: andromeda
maintainer: @andromeda:tchncs.de
-- A copyright notice.
-- copyright:
category: Development
build-type: Custom
build-type: Simple
extra-doc-files: CHANGELOG.md
-- Extra source files to be distributed with the package, such as examples, or a tutorial module.
-- extra-source-files:
common warnings
ghc-options:
-Wall
-Widentities
-Wincomplete-record-updates
-Wincomplete-uni-patterns
-Wpartial-fields
-Wredundant-constraints
custom-setup
setup-depends:
base,
Cabal,
process
library
import: warnings
exposed-modules: Lib
-- Modules included in this library but not exported.
-- other-modules:
-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
exposed-modules: RGFW
build-depends:
base >=4.18
base >=4.18,
bindings-DSL <1000
pkgconfig-depends:
gl,
x11,
xcursor,
xrandr,
xi
hs-source-dirs:
lib
hs-source-dirs: lib
include-dirs: include
default-language: Haskell2010
executable hs-rgfw
import: warnings
main-is: Main.hs
build-depends:
base >=4.18,
hs-rgfw
pkgconfig-depends:
gl,
x11,
xcursor,
xrandr,
xi
hs-source-dirs: src
include-dirs: include
c-sources: include/RGFW_HS.c
install-includes: RGFW_HS.h
default-language: Haskell2010

14033
include/RGFW.h Normal file

File diff suppressed because it is too large Load Diff

1
include/RGFW_HS.c Normal file
View File

@@ -0,0 +1 @@
#include "RGFW_HS.h"

14
include/RGFW_HS.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef RGFW_HS // avoid repeated imports
#define RGFW_HS
// TODO add actual include logic
#define RGFW_IMPLEMENTATION
#define RGFW_DEBUG
#define RGFW_OPENGL
#define Time X11Time // fixes namespace clash with GHC when building with Nix
#include "RGFW.h"
#undef Time
#endif

37
lib/RGFW.hsc Normal file
View File

@@ -0,0 +1,37 @@
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
#include <bindings.dsl.h>
module RGFW where
import Foreign.Ptr
#strict_import
#include <RGFW.h>
#synonym_t u8 , CChar
#opaque_t RGFW_window
#ccall RGFW_createWindow , CString -> CInt -> CInt -> CInt -> CInt -> CUInt -> IO (Ptr <struct RGFW_window>)
#synonym_t RGFW_windowFlags , CUInt
#num RGFW_windowNoBorder
#num RGFW_windowNoResize
#num RGFW_windowAllowDND
#num RGFW_windowHideMouse
#num RGFW_windowFullscreen
#num RGFW_windowTransparent
#num RGFW_windowCenter
#num RGFW_windowRawMouse
#num RGFW_windowScaleToMonitor
#num RGFW_windowHide
#num RGFW_windowMaximize
#num RGFW_windowCenterCursor
#num RGFW_windowFloating
#num RGFW_windowFocusOnShow
#num RGFW_windowMinimize
#num RGFW_windowFocus
#num RGFW_windowOpenGL
#num RGFW_windowEGL
#num RGFW_windowedFullscreen
#ccall RGFW_window_shouldClose , Ptr <struct RGFW_window> -> IO CUChar
#ccall RGFW_window_swapBuffers_OpenGL , Ptr <struct RGFW_window> -> IO ()

36
src/Main.hs Normal file
View File

@@ -0,0 +1,36 @@
module Main (main) where
import Foreign.C.String (withCString)
import RGFW
--------------------------------------------------------------------------------
-- main
--------------------------------------------------------------------------------
main :: IO ()
main = do
window <- withCString "window <3" (\name ->
c'RGFW_createWindow
name
0
0
800
600
$ sum
[ c'RGFW_windowNoResize
, c'RGFW_windowOpenGL
, c'RGFW_windowedFullscreen
]
)
putStrLn $ show window
let loop ctr = do
shouldClose <- c'RGFW_window_shouldClose window
if 0 /= shouldClose
then return shouldClose
else do
c'RGFW_window_swapBuffers_OpenGL window
loop $ ctr + 1
exitCode <- loop (0 :: Integer)
putStrLn $ show exitCode
return ()