Skip to content

u/lazycrypt

In this archive from May 2018 to Dec 2018

3
posts
11
comments
1
media
29
score

Top posts

Bluetooth mouse disconnecting randomly

So recently I decided to try out Arch on my laptop and so far I'm liking it and I've managed to set up most things. One issue that I do have that is starting to become a real deal braker for me is Bluetooth randomly disconnecting. And I do mean randomly, one time I can go without a disconnect for ho...

3 points3 comments
Open on Reddit

Top comments

I've been using Arch for about a year now and honestly, I haven't ran into any stability issues. I've had more things come broken out of the box using Ubuntu, with Arch things are only as broken as you make them.

2 points

I've used a thread pool that started as many threads as std::thread::hardware_concurrency reported. The thread pool also has a task queue and with the use of conditional variables I've set the worker function the threads ran so that if the queue was empty they would sleep.

So when the rendering portion of the application came out, they raycaster would create rays/tasks by passing information about the source and the direction of the rays. Once the queue would start filling up the threads would start calculating how far the columns are, what color to use and if they should be shaded (North/South sides use full brightness while West/East are half brigthness). So in the end you'd end up with two vertices representing a vertical line. These were then put into a vertex array and once the task queue was empty all the threads idle again the main thread would get woken up and the screen would get drawn then.

Roughly something like this:

  1. Thread pool with task queue and sleeping threads
  2. Main thread starts queing up tasks/rays
  3. Worker threads start calculating column vertices / Main thread sleeps during this step to prevent displaying a partial render
  4. Worker threads finish -> Wake up main thread
  5. Main thread calls the SFML function for drawing the vertex array

Though as it is, multithreading didn't prove to improve performance, mostly because most of the time was spent waiting on mutexes to unlock. If I remember right from benchmarking if you calculated how much time was spent on each ray, it took three times longer when doing it multithreaded than doing it single threaded. So when comparing the framerates there was a 30% loss in speed when switching to the multithreaded mode (I've made it so you could switch between the two at runtime).

2 points

I'd been pretty interested since I was thinking of doing something similar to the Doom or the Build engine. I've recently made a prototype of a Wolf3D-like raycasting engine in C++ using SFML.

I still have to do texture mapping in it but I'm at the point where I'm unsure if I should continue with the project because with my current implementation of raycasting it seems getting non-orthogonal walls at arbitrary heights would require a lot of hacks. And there is only so much you can do with a grid based map.

I'm also unsure if I should continue using SFML. It's great for prototyping stuff but I'm not sure how suitable is it for "real" game development?

2 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.