| 1 |
#include <iostream> |
| 2 |
#include <tchar.h> |
| 3 |
|
| 4 |
#pragma link "CastleWindow" |
| 5 |
|
| 6 |
#include "CastleWindow.hpp" |
| 7 |
#include "CastleApplicationProperties.hpp" |
| 8 |
#include "CastleLog.hpp" |
| 9 |
|
| 10 |
#include "GameInitialize.h" |
| 11 |
|
| 12 |
/* Configure ApplicationProperties, start logging. |
| 13 |
For Pascal projects, these calls are autogenerated in castleautogenerated.pas . |
| 14 |
None of these are critical for the project to really work, |
| 15 |
but we show how to express in C++ 100% of the API available from Pascal. */ |
| 16 |
void EarlyInitialization() |
| 17 |
{ |
| 18 |
ApplicationProperties()->ApplicationName = "CastleCppWindow"; |
| 19 |
ApplicationProperties()->Caption = "C++ Builder Demo Using TCastleWindow"; |
| 20 |
ApplicationProperties()->Version = "0.1"; |
| 21 |
if (!IsLibrary) { |
| 22 |
Application()->ParseStandardParameters(); |
| 23 |
} |
| 24 |
InitializeLog(); |
| 25 |
} |
| 26 |
|
| 27 |
/* Note: We define FMXMain, not _tmain, |
| 28 |
because for C++ Builder we recommend to define applications |
| 29 |
using TCastleWindow as "FMX application". Reasons: |
| 30 |
|
| 31 |
- This is the way to avoid console on Windows. |
| 32 |
Unlike Delphi/Pascal, where the {$apptype console} / {$apptype gui} |
| 33 |
determines application type (and it is independent from VCL / VFMX / other), |
| 34 |
with C++ Builder it seems that using a framework like FMX is the only way |
| 35 |
to avoid console. |
| 36 |
|
| 37 |
- On non-Windows (like Linux), TCastleWindow uses FMX under the hood. |
| 38 |
*/ |
| 39 |
|
| 40 |
//int _tmain(int argc, _TCHAR* argv[]) |
| 41 |
extern "C" int FMXmain() |
| 42 |
{ |
| 43 |
EarlyInitialization(); |
| 44 |
|
| 45 |
/* Sets Application()->MainWindow, Application()->OnApplicationInitialize */ |
| 46 |
GameInitialize(); |
| 47 |
|
| 48 |
/* Open Application()->MainWindow and run application loop */ |
| 49 |
Application()->MainWindow->OpenAndRun(); |
| 50 |
|
| 51 |
return 0; |
| 52 |
} |
| 53 |
|
| 54 |
// TODO: How to request from C++ to use dedicated GPU on laptops? |
| 55 |
// We do this in Pascal, see https://castle-engine.io/dedicated_gpu |
| 56 |
|