GMS 2 How i can create camera and view from code?



I use/read and display/cameras/camera_set_view_pos.html

I have a room 2560x1440.
And i want to see the center of my room in my game window 1024x768.
I can do it using room properties.
Let find the center. (2560-1024)/2=768, (1440-768)/2=336.
So camera properties will be X Pos=768, Y Pos=336, Width=1024, Height=768.
Viewport properties will be X Pos=0, Y Pos=0, Width=1024, Height=768.
Run-compile. Everything looks good.

But i need to do it from my code.
What i do
I create camera id=0. X Pos=768, Y Pos=336, Width=1024, Height=768. No angle, object etc.
view_camera[0] = camera_create_view(768, 336, 1024, 768, 0, 0, 0, 0, 0, 0);
And i see whole my room.
But i also need a viewport creation code and viewport setings code. And i can not find it in manual.
We can camera_create or camera_create_view with camera properties only.
And what about viewport_create?
How i can create camera and view from code?

You might want to check out some tutorials on youtube.

Shaun Spalding has a couple great ones, as usual:

If you are coming from GMS1 and just want everything to work like it used to, I have a video that helps convert the current system to work like GMS1. You might get what you need out of watching that.

This is complicated stuff, and you are definitely not the first to get tripped up by it. Even the documentation is a bit lacking in this area, so don't feel bad about getting stuck on it.