OGRE_NEXT documentation: using Ogre in your App

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
knn217
Halfling
Posts: 70
Joined: Wed Jan 25, 2023 9:04 am
x 5

OGRE_NEXT documentation: using Ogre in your App

Post by knn217 »

Hello, Im following the tutorial in the documentation for "using Ogre in your App", the empty project setup script is easy to use but its seems quite complicated so I tried to do it the normal way:

Include OgreMain/include
Include Components/Hlms/Common/include
Include Components/Hlms/Pbs/include
Include Components/Hlms/Unlit/include
Include build/Release/include (that's where OgreBuildSettings.h is)
Add the link path build/Release/lib/
Link against OgreHlmsPbs.lib
Link against OgreHlmsUnlit.lib
Link against OgreMain.lib
Bundle the data files in Samples/Media/Hlms/Common with your application
Bundle the data files in Samples/Media/Hlms/Pbs with your application
Bundle the data files in Samples/Media/Hlms/Unlit with your application

includes and links are simple, but what does bundle mean? Do I just copy the files to my application folder?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: OGRE_NEXT documentation: using Ogre in your App

Post by dark_sylinc »

Yes.

Just copy somewhere, because you will need to load them in your app (see GraphicsSystem::registerHlms in Samples/2.0/Common/src/GraphicsSystem.cpp particularly getDefaultPaths which returns paths to these Hlms folders).

Btw Tutorial00_Basic.cpp in Samples/2.0/Tutorials/Tutorial00_Basic is a very basic bare-bones example of how to setup OgreNext.

It doesn't have any of the recommended practices shown in the other tutorials, and it doesn't use SDL2 either (SDL2 is recommended), but it is very simple to understand on how to setup.

knn217
Halfling
Posts: 70
Joined: Wed Jan 25, 2023 9:04 am
x 5

Re: OGRE_NEXT documentation: using Ogre in your App

Post by knn217 »

Thanks for the reply, I copied the whole Hlms folder to my project folder: "OgreTutorial\Hlms" since this is what empty project script generated in "EmptyProject\bin\Data". Is this ok, or do I have to copy each individual folder (Common, Pbs, Unlit) like whats said in the documentation?

dark_sylinc wrote: Wed Jan 25, 2023 3:12 pm

Btw Tutorial00_Basic.cpp in Samples/2.0/Tutorials/Tutorial00_Basic is a very basic bare-bones example of how to setup OgreNext.

I just tried the example but had a problem with detecting entry point (Im on Windows btw). I checked the example's entry point in "properties -> linker -> advanced" setting but it wasn't changed, so how did the example project knows WinMain is the entry point? (Sorry for noob question, still new to C++ and VS)

Edit: After some digging, I made some progress, I linked my project against "SDL2.lib" and "SDL2main.lib" and it no longer complains about entry point. But now it can't find an external symbol "SDL_main", which .lib file has this? I found only 3 SDL related .lib files (SDL2.lib, SDL2main.lib, SDL2-static.lib) the last one didn't do anything, I assumed its for static build?

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: OGRE_NEXT documentation: using Ogre in your App

Post by dark_sylinc »

Hi!

The tutorial00 does NOT use SDL2, the rest do.

Including SDL2 libs fixes your linker issue because SDL2 must be defining an entry point.

As for your problem, the entry point is either int main( int argc, const char *argv[] ) or INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR strCmdLine, INT nCmdShow )

In Visual Studio this is normally controlled by Linker -> System -> SubSystem:

If the subsystem is set to Windows, then the entry point you must define is WinMain. If it's set to CONSOLE, then it is main.

Tutorial00 defines WinMain on Windows, so it expects you to set SubSystem to Windows.

knn217
Halfling
Posts: 70
Joined: Wed Jan 25, 2023 9:04 am
x 5

Re: OGRE_NEXT documentation: using Ogre in your App

Post by knn217 »

dark_sylinc wrote: Thu Jan 26, 2023 4:51 pm

As for your problem, the entry point is either int main( int argc, const char *argv[] ) or INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR strCmdLine, INT nCmdShow )
Tutorial00 defines WinMain on Windows, so it expects you to set SubSystem to Windows.

This worked, thanks! Now the project actually builds, but now its asking me for .dll files. I've copy every .dll files from "Ogre\build\bin\release" for good measure but its still missing "RenderSystem_Direct3D9.dll", where can I find this file?

Edit: Finally got it to work like the tutorial, turns out I just need to change my "Working Directory" to $(OutDir) in "Properties -> Debugging", after that just add .dll and.cfg files based on the "Ogre.log" file in the same folder as the project's .exe file (nice feature btw! Straight to the needed files, nothing hard to understand). Thanks dark_sylinc for the replies, couldn't have done it without your help!

knn217
Halfling
Posts: 70
Joined: Wed Jan 25, 2023 9:04 am
x 5

Re: OGRE_NEXT documentation: using Ogre in your App

Post by knn217 »

Here are the steps to create a project that works like Tutorial00_Basic in Visual Studio:

  1. Create a new Empty Project, create a "main.cpp" file, copy the code from "Tutorial00_Basic.cpp" to "main.cpp".
  2. Open your project's properties:
    In "Configuration Properties -> Debugging -> Working Directory" set to $(OutDir)
    In "Linker -> System -> SubSystem" set to Windows (/SUBSYSTEM:WINDOWS)
  3. Including and linking will be like in the Documentation's tutorial:
    Include OgreMain/include
    Include Components/Hlms/Common/include
    Include Components/Hlms/Pbs/include
    Include Components/Hlms/Unlit/include
    Include build/Release/include (that's where OgreBuildSettings.h is)
    Add the link path build/Release/lib/
    Link against OgreHlmsPbs.lib
    Link against OgreHlmsUnlit.lib
    Link against OgreMain.lib
    Bundle the data files in Samples/Media/Hlms/Common with your application
    Bundle the data files in Samples/Media/Hlms/Pbs with your application
    Bundle the data files in Samples/Media/Hlms/Unlit with your application
    (Bundling is just means copy and paste them somewhere in your application's directory)
  4. Build the project and run it.
  5. If there's a problem during run, check "Ogre.log" in your project's folder that contains the .exe file.

Hope this help!

Post Reply