#2d (ortho) camera with depth

22 messages · Page 1 of 1 (latest)

somber kelp
#

Update: So i got a weird setupfor my 3d ortho camera. But its wors then the 2d camera
the position and the target are(ScreenWidth/2 , ScreenHeight/2)
and the fovy is -WindowHeight
Because even though it sais it is the nearplane, it works more like a zoom
so if i want the cords for the window, i set it to the hieght, and then its flipped for some reason, so i do a - in front

But i then dont know how to draw anything, because DrawRectangle and DrawTexture still works, but there is no way to define which is on top of one other (appart from the order, but then tehre is no purpose)

So plzz help would be appriciated

#

(i have also read a lot of hisotry of this server contain the word Orthographic, but non of them spoke of drawing 2d things in a 3d thing like stardewvally)

dusky widget
#

all cameras in raylib are 3d, even the 2d camera.

#

tilemaps that support layers use draw order to handle depth

#

camera2d and the default 2d view still have a depth buffer

somber kelp
dusky widget
#

like read it?

#

normaly YOU don't need to read it from the CPU side

#

just draw at the corrext Z

somber kelp
dusky widget
#

use rlPushMatrix() rlTranslatef(0,0,YOUR_DEPTH); to draw something at any depth

#

you can push any z value to the transform stack you want

somber kelp
#

so if i want to move an object, i need to first do rlTransformf() and then drawX() and then rlTranformf for the next object

dusky widget
#

yes

#

you can rlPushMatrix() translate, draw, rlPopMatrix();

#

you can do that for each thing you want to draw

somber kelp
#

does it stack, or is it more like a state machine

dusky widget
#

it's a state machine with a stack

#

push and pop is what hits the stack, but the top is a compounding state

#

rlPushMatrix pushes a new matrix to the stack

somber kelp
#

oh wait, i didnt see the matrix part lol.

dusky widget
#

yeah it's all matrix stuff