Commit 101dbd50 authored by IC Rainbow's avatar IC Rainbow 🌈
Browse files

Expand gloss intro even more

parent 2fac08a1
Pipeline #222823718 passed with stages
in 28 seconds
......@@ -22,6 +22,7 @@ What kind of game do you want to make?
+ [Brick](intro-brick.md)
- Mobile
+ [Keera Hails](https://github.com/keera-studios/keera-hails)
- [Live-coding](intro-live.md) session
## Where to ask
......
......@@ -47,6 +47,48 @@ Or get a [profiler] report.
[sounds]: topic-sound.md
[profiler]: topic-profiling.md
## Elements provided
Gloss is all about building a scene - a value of type [Picture].
A picture can be one of:
- `Blank`, with nothing in it.
- Some vector primitives:
+ `Polygon` strictly convex polygon filled with a solid color.
+ `Line` a line along an arbitrary path.
+ `Circle` (filled) and `ThickCircle` (outline).
+ `Arc` (filled) and `ThickArc` (outline).
- `Color` for the primitives.
- `Text` to draw with a vector font.
- `Bitmap` and `BitmapSection` that can be used for sprites and atlases.
- Transformations:
+ `Translate`
+ `Rotate`
+ `Scale`
- And finally, more `Pictures` to put into transformations and coloring.
[Picture]: https://hackage.haskell.org/package/gloss-1.13.2.1/docs/Graphics-Gloss-Data-Picture.html
Without any transformations applied the `Picture` will be drawn in the middle of the screen, where the `(0, 0)` point lies.
Distance units are set in pixels and window size in `FullScreen` equals to pixel width and height.
You can query those with `getScreenSize`.
## Extensions
Out of the box it can only load `.bmp` files, but [gloss-juicy] adds `.jpg` and `.png` support without C dependencies.
SDL2 surfaces can be converted into gloss Picture with [gloss-sdl2-surface].
This opens up the way to have animated textures and big letters in nice [TrueType fonts].
There are quite a few packages on [Hackage] around
[gloss-juicy]: https://hackage.haskell.org/package/gloss-juicy
[gloss-sdl2-surface]: https://gitlab.com/dpwiz/gloss-sdl2-surface
[TrueType fonts]: https://hackage.haskell.org/package/sdl2-ttf
[Hackage]: https://hackage.haskell.org/packages/search?terms=gloss
## Limitations
It is backed by OpenGL, but most of the functions and display context are unavailable.
......@@ -75,11 +117,15 @@ And yet, it is certainly possible to make a real and complex game with fancy ani
You can inspect that to get a quickstart on OpenGL immediate mode rendering.
You'll get *the looks*, but it works good enough.
+ Use [OpenGL] bindings directly.
- Skip OpenGL and dive into GPU programming with [Vulkan].
- Go [world-wide] with a related library in a browser.
[ECS]: package-apecs-gloss.md
[gloss-raster]: https://hackage.haskell.org/package/gloss-raster
[gloss-rendering]: https://hackage.haskell.org/package/gloss-rendering
[OpenGL]: https://hackage.haskell.org/package/OpenGL
[OpenGL]: intro-opengl.md
[Vulkan]: intro-vulkan.md
[world-wide]: https://code.world/haskell
[[z:zettels?tag=package&tag=gloss]]
......
......@@ -7,7 +7,7 @@ tags: [package, gloss]
- Hackage: <https://hackage.haskell.org/package/gloss>
- Source: <https://github.com/benl23x5/gloss>
> Gloss hides the pain of drawing simple vector graphics behind a nice data type and a few display functions.
> Gloss hides the pain of drawing simple vector graphics behind a nice data type and a few display functions. Gloss uses OpenGL under the hood, but you won't need to worry about any of that. Get something cool on the screen in under 10 minutes.
## Minimal example
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment