Use RGBA for the uint32_t color pixels. Closes #49.
This commit is contained in:
parent
ab1a415b55
commit
cad51f4908
1 changed files with 5 additions and 5 deletions
|
@ -22,7 +22,7 @@ union ColorConv {
|
|||
uint8_t b;
|
||||
uint8_t a;
|
||||
} as_color;
|
||||
uint32_t as_int;
|
||||
RGBA as_int;
|
||||
};
|
||||
|
||||
// from: https://permadi.com/1996/05/ray-casting-tutorial-19/
|
||||
|
@ -40,7 +40,7 @@ union ColorConv {
|
|||
* and I guess the compiler can handle it better than shifting
|
||||
* bits around.
|
||||
*/
|
||||
inline uint32_t lighting_calc(uint32_t pixel, float dist, int level) {
|
||||
inline RGBA lighting_calc(RGBA pixel, float dist, int level) {
|
||||
ColorConv conv{.as_int=pixel};
|
||||
|
||||
if(conv.as_color.b < GLOW_LIMIT
|
||||
|
@ -327,8 +327,8 @@ void Raycaster::draw_ceiling_floor() {
|
|||
constexpr static const int texture_height = TEXTURE_HEIGHT;
|
||||
auto &lights = $level.lights->lighting();
|
||||
size_t surface_i = 0;
|
||||
const uint32_t *floor_texture = textures::get_surface(surface_i);
|
||||
const uint32_t *ceiling_texture = textures::get_ceiling(surface_i);
|
||||
const RGBA *floor_texture = textures::get_surface(surface_i);
|
||||
const RGBA *ceiling_texture = textures::get_ceiling(surface_i);
|
||||
|
||||
for(int y = $height / 2 + 1; y < $height; ++y) {
|
||||
// rayDir for leftmost ray (x=0) and rightmost (x = w)
|
||||
|
@ -375,7 +375,7 @@ void Raycaster::draw_ceiling_floor() {
|
|||
floor_y += floor_step_y;
|
||||
|
||||
// now get the pixel from the texture
|
||||
uint32_t color;
|
||||
RGBA color;
|
||||
// this uses the previous ty/tx fractional parts of
|
||||
// floor_x cell_x to find the texture x/y. How?
|
||||
int map_x = int(floor_x);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue