Skip to content

Commit

Permalink
Merge branch 'latest' of github.com:vuelto-org/vuelto into latest
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkauzh committed Jan 5, 2025
2 parents 7097008 + f771600 commit a06b46c
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 9 deletions.
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Vuelto Changelog

## Vuelto 1.1 (05/01/2025)

### Breaking changes

- Updated to OpenGL 3.3 Core, breaking compatibility with unsupported hardware.
- `DrawLine()` now takes arguments in the order `x1 y1 x2 y2`, instead of `x1 x2 y1 y2`.
- `Image` struct now uses a `Pos` parameter with `Vector2D` type instead of `X,Y` `float32` param for position.
- `Line` struct now uses `Pos1` and `Pos2` params with `Vector2D` type instead of `X1, Y1, X2, Y2`.
- `Rect` struct now uses `Pos` param with `Vector2D` type instead of `X, Y`.

### Additions

- Support for targeting web (WASM + WebGL 2.0).
- Event system
- KeyPressed, KeyPressedOnce, and KeyReleased
- Mouse position
- `GetDeltaTime()`
- Framerate managing
- `GetFPS()`
- `SetFPS()`

### Changes

- The above mentioned breaking changes.
- Params `X` and `Y` (and `Z`) for `Vector2D` and `Vector3D` are now of type `float32` instead of `float64`.
- Improved performance.

<!-- TODO: review older versions and log their changes -->
3 changes: 1 addition & 2 deletions pkg/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
package vuelto

type Renderer2D struct {
Window *Window
LegacyGL bool
Window *Window
}

// Creates a new renderer thats connected to the window.
Expand Down
5 changes: 4 additions & 1 deletion website/blog/.authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ authors:
name: Zaka
description: Vuelto Team
avatar: https://0.gravatar.com/avatar/97d096fa42833c482e4e2f5636421ac224790ff071e431e59448f01e27dce5d2?size=512
# todo: add Dima
# dimkauzh: uncomment when we got an avatar for bro (no avatar = failed build)
# name: Dima
# description: Vuelto Founder
# avatar: todo ig
Binary file added website/blog/assets/vuelto-1-1-cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
137 changes: 137 additions & 0 deletions website/blog/posts/vuelto-1-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
draft: false
date: 2025-01-05
categories:
- Updates
- Releases
authors:
- zaka
slug: vuelto-1-1-release
pin: true
readtime: 5 # more or less
---

# Vuelto 1.1 released\! Here's what's new

![Post cover](../assets/vuelto-1-1-cover.png)

Hi there! Happy new year to everyone. We’re *a bit* late, but still hyped to give you everyone this year’s gift: **Vuelto 1.1!** While it’s a *minor* update from a user perspective, it’s a whole revamp of Vuelto’s internals, bringing - among other things - support for making web-based games from the same codebase! We also improved performance, made the groundwork for the now available events system, and even more. So let's dive into it!

<!-- more -->
## The new Vuelto renderer

Vuelto 1.0’s legacy renderer uses a pipelined system for rendering graphics. It looks kinda like this:

```go
// ...
gl.Vertex2f(x, y)
gl.Vertex2f(x+width, y)
gl.Vertex2f(x+width, y+height)
gl.Vertex2f(x, y+height)
// ...
```

Vuelto 1.1 refactored the rendering system, using OpenGL 3.3 Core and taking a shader based approach like this:

```go
vertexShader := NewShader(VERTEX_SHADER, "vertex_shader_web.glsl", "vertex_shader_desktop.glsl")
fragmentShader := NewShader(FRAGMENT_SHADER, "fragment_shader_web.glsl", "fragment_shader_desktop.glsl")

vertexShader.Compile()
fragmentShader.Compile()

program := NewProgram(*vertexShader, *fragmentShader)
program.Link()
program.Use()
```

This brings in performance improvements and sets the groundwork for supporting advanced features like material textures in future versions.

!!! note
Keep in mind GL 3.3 is not compatible with super old hardware. The legacy renderer has been removed, so you’ll have to stick with it.

## Web support

Now Vuelto is capable of compiling your games to both the desktop with GLFW and the web with WebAssembly and WebGL from the same codebase! That’s made possible thanks to a bunch of refactors to the widowing system that, besides improving code maintainability, made this possible. All features supported by Vuelto will work seamlessly on the web, we’ll take care of code splitting and conversion everywhere possible.

There are two exceptions for this, as of now:

- Images won’t work on the web by default. If you’re targeting web & desktop at the same time, a small different approach is needed.
- Games that launch more than one window won’t work on the web at all.

In the end, as long as you don’t open two windows on the web and use `ImageEmbed` instead of an image path (more onto that later), your Vuelto games are now fully cross-platform: Linux, Windows, macOS, and the web.

## Enhanced windowing and rendering

We just told you that we refactored the windowing system. This doesn’t only bring the almighty web support, but also adds **framerate management**. You can now get the framerate of your game with `window.GetFPS()`, or even better, you can **set your window’s framerate** with `window.SetFPS()`.

And besides that, a function most game devs can’t get off their head and somehow wasn’t in Vuelto - until now. **`window.GetDeltaTime()`**! Finally, we brought this good boy in.

Another change, regarding the previously mentioned image support for the web, is that now images support embedding.

The classic way to render an image in Vuelto is to go this:

```go
image := renderer.LoadImage("path/to/image.png", 10, 10, 50, 50) // returns an Image (internal type)
```

This works fine, but only on the desktop. For an image that works both on the desktop and the web, you’ll need an ImageEmbed instead of a file path.

An ImageEmbed struct takes two parameters, Filesystem, which should always be embed.FS, and then the filename of the image to use.

```go
var embeddedFiles embed.FS

imageEmbed := vuelto.ImageEmbed{
Filesystem: embeddedFiles,
Image: "image.png",
}

image := renderer.LoadImage(imageEmbed, 0, 0, 1, 1)
```

Once loaded like this, you can just do image.Draw(), and you now got a web-proof image on screen.

## Events system

As promised in our birthday blog post, we’re bringing events to Vuelto. They are still basic, but the groundwork made so far is sufficient for making v1.1 a great release, and also sets a base we’ll build on top of in the following releases. For now you can get **key press** and **key release** events reactively, and the **mouse position** imperatively.

Key press & release events are used like this:

```go
if KeyPressed(“E”) == true {
fmt.Println(“you pressed it”)
}
// ...
if KeyReleased(“E”) {
fmt.Println(“you’re not pressing it”)
}
```

We said you can get these “reactively” because the boolean return of both functions immediately switches as soon as the user toggles the event. `”you pressed it”` will be immediately printed each time I press `E`, as each time the event is fired, the state of the function changes, firing the code inside the `if` block. The same happens with release events, each time I release the `E` key, `”you’re not pressing it”` would print.

Keep in mind code inside `if KeyPressed(“E”)` will fire multiple times - one per frame, actually. `KeyPressed(“E”)` will stay true until I release the key, and the window’s life-cycle itself is a loop, so events get fired repeatedly.

If you need to fire code only once, you can use `KeyPressedOnce(“E”)`.

Besides these, we also have `MousePos()` (not *Get*MousePos())

```go
position := window.MousePos() // imagine X is 20 and Y is 30
```

From here, we can access `position.X`, which will return 20, `position.Y`, which will return 30, and `position.Pos()` to get both together as `20, 30`.

Keep in mind the `position` variable won’t change as the window refreshes. That’s why we said *you can get it “imperatively”*. `MousePos()` returns the value for the moment of the call and doesn’t update it, so you’ll have to call `MousePos()` exactly where you want to use it (or just use some sort of loop).

## Better documentation

Vuelto 1.0 was, to be honest, almost documentation less. We’ve fixed that! Here, at vuelto.pp.ua, Vuelto 1.1 is now fully documented and includes code examples, easy to follow explanations on core concepts such as the game loop, and more. All of that with that nicely refreshed branding we told you about on our last (and first too!) blog post. It’s something to be proud of, isn’t it?
And that’s all, my fellows! We hope you’re as excited to try out Vuelto 1.1 as we are to release it right now. See the full release notes at our [CHANGELOG.md file](https://github.com/vuelto-org/vuelto/blob/main/CHANGELOG.md), and have fun with it!

Best wishes for this newly started year from the Vuelto team.

Onward and upward,

> Zaka, from the Vuelto Team.
12 changes: 6 additions & 6 deletions website/blog/posts/were-one-year-old.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ categories:
authors:
- zaka
slug: were-one-year-old
pin: true
pin: false
readtime: 3 # more or less
---

![Post cover](../assets/were-one-year-old-cover.png)
# We’re one year old\! V1.1 is coming, and it’s looking good

# We’re one year old\! V1.1 is coming, and it’s looking good\!
![Post cover](../assets/were-one-year-old-cover.png)

Hi there\! I’m [Zaka](https://github.com/ZakaHaceCosas), and I’m a new addition to the Vuelto Team, though I’ve known this engine for a while. Feels like it’s already been a year since I got to know this engine \- and indeed, it has been a year since it was made\! Today, one year ago, Vuelto was created as an alternative to [Fusion Engine](https://github.com/fusionengine-org/fusion), another engine made by the same creator.

We at Vuelto have been cooking a new release for a while now, and while it’s not ready for today as we still work on it, it’s coming soon (in fact, there’s already a [PR draft](https://github.com/vuelto-org/vuelto/pull/8)), and it’s looking pretty neat.

<!-- more -->
## New rendering system approach

Currently, Vuelto 1.0 uses a pipelined system for rendering graphics. It looks kinda like this:
Expand Down Expand Up @@ -70,7 +71,7 @@ window.Resizable = resizable

\- you now have something that works with both the web and GLFW. Under the hood, Vuelto will take care of code filtering for each platform, so you don’t gotta worry about that.

## Events\!
## Events\

*There’s less progress on this area* BUT \- it’s a thing, and it’s coming in V1.1\! While this is still in early stages and subject to changes, for now the idea is to make them using a boolean (`true`/`false`) structure.

Expand All @@ -94,7 +95,6 @@ vuelto.GetMousePox().Y // 131

!!! note
Keep in mind that the function returns the value for the moment of the call.

The value is not “reactive” like a web dev would say, so if you want to constantly keep track of the value, you’ll have to use some sort of loop.

## Better engine, better looks
Expand All @@ -109,5 +109,5 @@ And that’s all, my fellows\! Again, this is still in the works, V1.1 will have

For now, happy birthday, Vuelto\!

God bless you,
Onward and upward,
> \- [Zaka](https://github.com/ZakaHaceCosas), from the Vuelto Team.

0 comments on commit a06b46c

Please # to comment.