wolf4earth

wolf4earth

Hands-on Rust: B4.0 changing initialization code to use graphics (page 140)

On page 140 we change the initialization code of the dungeon crawler to be able to use graphics

As with other code examples before the relevant lines are annotated and explained afterwards. What I’ve noticed (and briefly struggled with) is that the first line also changed from:

let context = BTermBuilder::simple80x50()

to:

let context = BTermBuilder::new()

The change is small and easy to miss while the consequences are quite grave. If one misses the change and leaves the first line as BTermBuilder::simple80x50() the program will crash on startup with the following error:

thread 'main' panicked at 'Failed to load texture: IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })', /Users/swolf/.cargo/registry/src/github.com-1ecc6299db9ec823/bracket-terminal-0.8.1/src/hal/gl_common/font.rs:41:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I suggest to also highlight the change from BTermBuilder::simple80x50() to BTermBuilder::new() with an additional explanation on why this is necessary.

On another note: I’m very much enjoying the book. :slightly_smiling_face:

Marked As Solved

herbert

herbert

Author of Hands-on Rust

Good catch, thank you! I’ll get that into the issue tracker and have it resolved for beta 5.

Popular Pragmatic topics Top

New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
PragmaticBookshelf
A Hero’s Journey with Chris Pine @chrispine Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1127 25299 748
New

Latest in PragProg

View all threads ❯