User Tools

Site Tools


en:guides:beginners:viewport_and_camera

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en:guides:beginners:viewport_and_camera [2024/11/17 02:31 (10 months ago)] – Fixes and alignment to newer orx. sausageen:guides:beginners:viewport_and_camera [2025/08/20 09:40 (3 weeks ago)] (current) – updated the example to reflect the current template lattay
Line 53: Line 53:
 </code> </code>
  
-The viewport needs to be created when our game runs, so let's take a look at the MyGame.cpp code:+The viewport needs to be created when our game runs, so let's take a look at the MyGame.code (for a C++ project, look for ''MyGame::Init'' in MyGame.cpp):
  
-<code=cpp>+<code=c>
 orxSTATUS orxFASTCALL Init() orxSTATUS orxFASTCALL Init()
 { {
  
-    orxViewport_CreateFromConfig("MainViewport");+... 
 +  orxConfig_PushSection("Main"); 
 + 
 +  for(orxS32 i = 0, iCount = orxConfig_GetListCount("ViewportList"); i < iCount; i++) 
 +  { 
 +    orxViewport_CreateFromConfig(orxConfig_GetListString("ViewportList", i)); 
 +  } 
 </code> </code>
  
-Nice and simple. Our project already has this added. The Init() function runs once when your game first executes, and this is where the viewport is created.+Here the ''"ViewportList"'' refers to this section of the config file: 
 +<code ini> 
 +[Main] 
 +ViewportList    = MainViewport 
 +</code> 
 + 
 +You could also called ''orxViewport_CreateFromConfig'' on a static name: 
 +<code=c> 
 +orxSTATUS orxFASTCALL Init() 
 +
 + 
 +... 
 +   
 +    orxViewport_CreateFromConfig("MainViewport"); 
 + 
 +</code>
  
 +The Init() function runs once when your game first executes, and this is where the viewport is created.
  
 The "MainViewport" string parameter specified in that function is the same name as the ''[MainViewport]'' section in the config. The "MainViewport" string parameter specified in that function is the same name as the ''[MainViewport]'' section in the config.
en/guides/beginners/viewport_and_camera.txt · Last modified: 2025/08/20 09:40 (3 weeks ago) by lattay