User Tools

Site Tools


en:tutorials:shaders:lighting

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:orx:tutorials:lighting [2011/03/10 17:08 (13 years ago)] – Added config iarwainen:tutorials:shaders:lighting [2020/08/31 08:56 (4 years ago)] (current) – ↷ Links adapted because of a move operation iarwain
Line 3: Line 3:
 ===== Summary ===== ===== Summary =====
  
-This is our third stand alone tutorial, written in plain ''C'', showing how to use shaders for lighting with autogenerated normal maps.\\ +This is tutorial shows how to use shaders for lighting with auto-generated normal maps.\\ 
-//NB: If you want to see how to use orx while using ''C++'' for your game, or if you want to learn the basics about how to create a stand alone with orx, please refer to the [[standalone|stand alone/locale tutorial]].//+//NB: If you want to see how to use orx while using ''C++'' for your game, please refer to the [[..:localization:locale|localization tutorial]].//
  
 As we are **NOT** using the default executable anymore for this tutorial, the tutorial code will be directly built into the executable and not into an external library. As we are **NOT** using the default executable anymore for this tutorial, the tutorial code will be directly built into the executable and not into an external library.
  
-See previous [[main#Basic|basic tutorials]] for more info about basic [[object|object creation]], [[clock|clock handling]], [[frame|frames hierarchy]], [[anim|animations]], [[viewport|cameras & viewports]], [[sound|sounds & musics]], [[FX|FXs]], [[physics]], [[scrolling]]. [[standalone|C++ stand alone & localization]] and [[spawner| spawner & shader]].+See previous basic tutorials for more info about basic [[..:objects:object|object creation]], [[..:clocks:clock|clock handling]], [[..:objects:frame|frames hierarchy]], [[..:animation:anim|animations]], [[..:viewport:viewport|cameras & viewports]], [[..:audio:sound|sounds & musics]], [[..:fx:fx|FXs]], [[..:physics:physics]], [[..:scrolling]]. [[..:localization:locale|C++ localization]] and [[..:spawners:spawner| spawner & shader]].
  
 This tutorial shows how to generate normal maps and use shaders for pixel-based lighting effects.\\ This tutorial shows how to generate normal maps and use shaders for pixel-based lighting effects.\\
Line 46: Line 46:
  
   orxEvent_AddHandler(orxEVENT_TYPE_SHADER, EventHandler);   orxEvent_AddHandler(orxEVENT_TYPE_SHADER, EventHandler);
-  orxEvent_AddHandler(orxEVENT_TYPE_OBJECT, EventHandler);+  orxEvent_AddHandler(orxEVENT_TYPE_TEXTURE, EventHandler);
  
   pstTextureTable = orxHashTable_Create(16, orxHASHTABLE_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);   pstTextureTable = orxHashTable_Create(16, orxHASHTABLE_KU32_FLAG_NONE, orxMEMORY_TYPE_MAIN);
Line 117: Line 117:
  
 <code c> <code c>
-  else if((_pstEvent->eType == orxEVENT_TYPE_OBJECT) && (_pstEvent->eID == orxOBJECT_EVENT_CREATE))+  else if((_pstEvent->eType == orxEVENT_TYPE_TEXTURE) && (_pstEvent->eID == orxTEXTURE_EVENT_LOAD))
   {   {
-    orxGRAPHIC *pstGraphic; +    CreateNormalMap(orxTEXTURE(_pstEvent->hSender));
-    pstGraphic = orxOBJECT_GET_STRUCTURE(orxOBJECT(_pstEvent->hSender), GRAPHIC); +
-    if(pstGraphic) +
-    { +
-      CreateNormalMap(orxTEXTURE(orxGraphic_GetData(pstGraphic))); +
-    }+
   }   }
  
Line 130: Line 125:
 }</code> }</code>
  
-When a ''orxOBJECT_EVENT_CREATE'' event is catched, we'll get it's orxGRAPHIC component and create a normal map for its texture.\\ +When a ''orxTEXTURE_EVENT_LOAD'' event is caught, we'll create a normal map for the concerned texture.\\ 
-This means that a normal map for a given texture is created the first time an object using that texture is created by calling ''CreateNormalMap()''.\\+This means that a normal map for a given texture is created by calling ''CreateNormalMap()'' the first time a texture is loaded.\\
 Let's have a look to that function more closely. Let's have a look to that function more closely.
  
Line 364: Line 359:
 ===== Resources ===== ===== Resources =====
  
-Source code: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/tutorial/src/12_Lighting/12_Lighting.c|12_Lighting.c]] +Source code: [[https://github.com/orx/orx/blob/master/tutorial/src/12_Lighting.c|12_Lighting.c]]
- +
-Config file: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/tutorial/bin/12_Lighting.ini|12_Lighting.ini]]+
  
 +Config file: [[https://github.com/orx/orx/blob/master/tutorial/bin/12_Lighting.ini|12_Lighting.ini]]
en/tutorials/shaders/lighting.1299805733.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)