Browse Source

Moved OgreInitialize into Cakelisp code

* Add monkey material and mesh
* Rename and move Ogre files
* Updated Cakelisp for CStatementOutput
master
Macoy Madson 1 month ago
parent
commit
871092aeed
10 changed files with 310 additions and 336 deletions
  1. +1
    -1
      Build_Debug.sh
  2. +1
    -1
      Dependencies/cakelisp
  3. +4
    -6
      src/Ogre.cake
  4. +276
    -0
      src/OgreInitialize.cake
  5. +0
    -325
      src/OgreInitialize.cpp
  6. +24
    -0
      test/data/Materials/Monkey_Fur.material
  7. BIN
      test/data/Models/Suzanne.mesh
  8. +1
    -1
      test/src/OgreApp.cake
  9. +1
    -1
      test/src/SDLOgreApp.cake
  10. +2
    -1
      test/src/VocalGame.cake

+ 1
- 1
Build_Debug.sh View File

@ -1,7 +1,7 @@
#!/bin/sh
# TODO: Support compiling as a library?
# ./Dependencies/cakelisp/bin/cakelisp src/OgreCore.cake || exit $?
# ./Dependencies/cakelisp/bin/cakelisp src/Ogre.cake || exit $?
# ./Dependencies/cakelisp/bin/cakelisp --verbose-processes test/src/OgreApp.cake
# ./Dependencies/cakelisp/bin/cakelisp --verbose-compile-time-build-objects test/src/SDLOgreApp.cake


+ 1
- 1
Dependencies/cakelisp

@ -1 +1 @@
Subproject commit 1dba3db6cc71a9efce8ee4328f4f31a557ca03c0
Subproject commit 0fb84053246c94daf30204136add2863a04db40a

src/OgreCore.cake → src/Ogre.cake View File

@ -1,6 +1,8 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(import &comptime-only "Macros.cake")
(import
"OgreInitialize.cake"
&comptime-only "Macros.cake")
(c-import "<stdio.h>"
;; Ogre dependencies
@ -11,9 +13,7 @@
"OgreMeshManager2.h"
"OgreRoot.h"
"OgreSceneManager.h"
"OgreWindowEventUtilities.h"
;; Not ported over to Cakelisp yet
"OgreInitialize.hpp")
"OgreWindowEventUtilities.h")
;; Use Ogre's GLX window
;; TODO: convert these functions to cakelisp eventually
@ -113,8 +113,6 @@
;; TODO: Relative vs. absolute paths
(import &comptime-only "../Dependencies/cakelisp/runtime/Macros.cake")
(add-cpp-build-dependency "OgreInitialize.cpp")
(add-build-options "-DOGRE_DEBUG_MODE=1")
(add-c-search-directory "Dependencies/ogre-next/OgreMain/include"
"Dependencies/ogre-next/Components/Hlms/Common/include"

+ 276
- 0
src/OgreInitialize.cake View File

@ -0,0 +1,276 @@
(import &comptime-only "Macros.cake")
(add-build-options "-DOGRE_DEBUG_MODE=1")
(add-c-search-directory "Dependencies/ogre-next/OgreMain/include"
"Dependencies/ogre-next/Components/Hlms/Common/include"
"Dependencies/ogre-next/Components/Hlms/Pbs/include"
"Dependencies/ogre-next/Components/Hlms/Unlit/include"
"Dependencies/ogre-next/build/Debug/include"
"Dependencies/ogre-next/Components/Overlay/include")
;; #pragma GCC diagnostic push
;; #pragma GCC diagnostic ignored "-Woverloaded-virtual"
(c-import
"OgreArchiveManager.h"
"OgreCamera.h"
"OgreConfigFile.h"
"OgreRoot.h"
"OgreWindow.h"
"OgreHlmsManager.h"
"OgreHlmsPbs.h"
"OgreHlmsUnlit.h"
"OgreItem.h"
"OgreMesh.h"
"OgreMesh2.h"
"OgreMeshManager.h"
"OgreMeshManager2.h"
"Compositor/OgreCompositorManager2.h"
"OgreWindowEventUtilities.h")
;; #pragma GCC diagnostic pop
(forward-declare
(namespace Ogre
(class Root)
(class SceneManager)))
(global-var g_ogreRoot (* (in Ogre Root)) null)
(var g_sceneManager (* (in Ogre SceneManager)) null)
(var g_window (* (in Ogre Window)) null)
(var g_graphicsIntialized bool false)
(global-var g_ogreWindowShouldQuit bool false)
;; TODO: Add advanced class definition
;; class MyWindowEventListener : public Ogre::WindowEventListener
;; {
;; public:
;; virtual void windowClosed(Ogre::Window* window)
;; {
;; g_ogreWindowShouldQuit = true;
;; }
;; };
;; (var g_myWindowEventListener MyWindowEventListener)
(defun-local registerHlms ()
(var resourcePath (in Ogre String) "data/")
(var cf (in Ogre ConfigFile))
(on-call cf load (+ resourcePath "resources2.cfg"))
(var rootHlmsFolder (in Ogre String)
(+ resourcePath (on-call cf getSetting "DoNotUseAsResource" "Hlms" "")))
(cond ((on-call rootHlmsFolder empty)
(set rootHlmsFolder "./"))
((!= (deref (- (on-call rootHlmsFolder end) 1)) '/')
(set rootHlmsFolder (+ rootHlmsFolder "/"))))
;; At this point rootHlmsFolder should be a valid path to the Hlms data folder
(var hlmsUnlit (* (in Ogre HlmsUnlit)) null)
(var hlmsPbs (* (in Ogre HlmsPbs)) null)
;; For retrieval of the paths to the different folders needed
(var mainFolderPath (in Ogre String))
(var libraryFoldersPaths (in Ogre StringVector))
(var libraryFolderPathIt (in Ogre StringVector const_iterator))
(var libraryFolderPathEn (in Ogre StringVector const_iterator))
(var archiveManager (& (in Ogre ArchiveManager)) (call (in Ogre ArchiveManager getSingleton)))
(scope ;; Create & Register HlmsUnlit
;; Get the path to all the subdirectories used by HlmsUnlit
(call (in Ogre HlmsUnlit getDefaultPaths) mainFolderPath libraryFoldersPaths)
(var archiveUnlit (* (in Ogre Archive))
(on-call archiveManager load (+ rootHlmsFolder mainFolderPath) "FileSystem" true))
(var archiveUnlitLibraryFolders (in Ogre ArchiveVec))
(set libraryFolderPathIt (on-call libraryFoldersPaths begin))
(set libraryFolderPathEn (on-call libraryFoldersPaths end))
(while (!= libraryFolderPathIt libraryFolderPathEn)
(var archiveLibrary (* (in Ogre Archive))
(on-call archiveManager load
(+ rootHlmsFolder (deref libraryFolderPathIt)) "FileSystem" true))
(on-call archiveUnlitLibraryFolders push_back archiveLibrary)
(incr libraryFolderPathIt))
;; Create and register the unlit Hlms
(set hlmsUnlit (ogre-new (call (type (in Ogre HlmsUnlit)) archiveUnlit
(addr archiveUnlitLibraryFolders))))
(on-call-ptr (on-call (call (in Ogre Root getSingleton)) getHlmsManager) registerHlms hlmsUnlit))
(scope ;; Create & Register HlmsPbs
;; Do the same for HlmsPbs:
(call (in Ogre HlmsPbs getDefaultPaths) mainFolderPath libraryFoldersPaths)
(var archivePbs (* (in Ogre Archive))
(on-call archiveManager load
(+ rootHlmsFolder mainFolderPath) "FileSystem" true))
;; Get the library archive(s)
(var archivePbsLibraryFolders (in Ogre ArchiveVec))
(set libraryFolderPathIt (on-call libraryFoldersPaths begin))
(set libraryFolderPathEn (on-call libraryFoldersPaths end))
(while (!= libraryFolderPathIt libraryFolderPathEn)
(var archiveLibrary (* (in Ogre Archive))
(on-call archiveManager load
(+ rootHlmsFolder (deref libraryFolderPathIt)) "FileSystem" true))
(on-call archivePbsLibraryFolders push_back archiveLibrary)
(incr libraryFolderPathIt))
;; Create and register
(set hlmsPbs (ogre-new (call (type (in Ogre HlmsPbs)) archivePbs
(addr archivePbsLibraryFolders))))
(on-call-ptr (on-call (call (in Ogre Root getSingleton)) getHlmsManager) registerHlms hlmsPbs))
(var renderSystem (* (in Ogre RenderSystem))
(on-call-ptr (call (in Ogre Root getSingletonPtr)) getRenderSystem))
(when (= (on-call-ptr renderSystem getName) "Direct3D11 Rendering Subsystem")
;; Set lower limits 512kb instead of the default 4MB per Hlms in D3D 11.0
;; and below to avoid saturating AMD's discard limit (8MB) or
;; saturate the PCIE bus in some low end machines.
(var supportsNoOverwriteOnTextureBuffers bool)
(on-call-ptr renderSystem getCustomAttribute "MapNoOverwriteOnDynamicBufferSRV"
(addr supportsNoOverwriteOnTextureBuffers))
(unless supportsNoOverwriteOnTextureBuffers
(on-call-ptr hlmsPbs setTextureBufferDefaultSize (* 512 1024))
(on-call-ptr hlmsUnlit setTextureBufferDefaultSize (* 512 1024)))))
(defun OgreInitialize (useCurrentWindow bool &return bool)
(var pluginsFolder (const (in Ogre String)) "./data/")
(var writeAccessFolder (const (in Ogre String)) "./output/")
;; TODO: Support preprocessor?
;; #ifndef OGRE_STATIC_LIB
;; #if OGRE_DEBUG_MODE
(var pluginsFile (* (const char)) "plugins_d.cfg")
;; #else
;; const char* pluginsFile = "plugins.cfg";
;; #endif
;; #endif
(set g_ogreRoot (ogre-new (call (in Ogre Root) (+ pluginsFolder pluginsFile)
(+ writeAccessFolder "ogre.cfg")
(+ writeAccessFolder "Ogre.log"))))
;; This allows the user to configure the graphics. It's damn annoying during dev though
;; TODO: Make this return false and quit the app
;; if (!g_ogreRoot->showConfigDialog())
;; return false;
;; Initialize Root
(var renderSystem (* (in Ogre RenderSystem))
(on-call-ptr g_ogreRoot getRenderSystemByName "OpenGL 3+ Rendering Subsystem"))
(unless renderSystem
(printf "Render system not found!\n")
(return false))
;; renderSystem->setConfigOption("Display Frequency", "N/A");
(on-call-ptr renderSystem setConfigOption "Full Screen" "No")
;; renderSystem->setConfigOption("VSync", "Yes");
(on-call-ptr renderSystem setConfigOption "Video Mode" "1920 x 1080")
(on-call-ptr renderSystem setConfigOption "sRGB Gamma Conversion" "Yes")
(on-call-ptr g_ogreRoot setRenderSystem renderSystem)
(set g_window (on-call-ptr g_ogreRoot initialise
(not useCurrentWindow) ;; autoCreateWindow
"GameLib"))
;; Use the already existing window
;; See http:;;wiki.ogre3d.org/Using+SDL+Input (that actually didn't work 100%)
(when useCurrentWindow
(var windowSettings (in Ogre NameValuePairList))
;; TODO: There is a scary comment about using this option in GLXWindow::create(). It may
;; cause problems later. The documentation for this stuff is sorely lacking
(set (at "currentGLDrawable" windowSettings) (call (type (in Ogre String)) "True"))
(set (at "currentGLContext" windowSettings) (call (type (in Ogre String)) "True"))
(var winWidth int 1920)
(var winHeight int 1080)
(set g_window (on-call-ptr g_ogreRoot createRenderWindow "GameLib" winWidth winHeight
false ;; Fullscreen
(addr windowSettings)))
;; renderWindow->setVisible(true);
)
(registerHlms)
;; Create SceneManager
(var numThreads (const size_t) 1u)
(set g_sceneManager (on-call-ptr g_ogreRoot createSceneManager
(in Ogre ST_GENERIC) numThreads "SceneManager"))
;; Create & setup camera
(var camera (* (in Ogre Camera)) (on-call-ptr g_sceneManager createCamera "Main Camera"))
;; Position it at 500 in Z direction
(on-call-ptr camera setPosition (call (type (in Ogre Vector3)) 0 5 15))
;; Look back along -Z
(on-call-ptr camera lookAt (call (type (in Ogre Vector3)) 0 0 0))
(on-call-ptr camera setNearClipDistance 0.2f)
(on-call-ptr camera setFarClipDistance 1000.0f)
(on-call-ptr camera setAutoAspectRatio true)
;; Setup a basic compositor with a blue clear colour
(var compositorManager (* (in Ogre CompositorManager2))
(on-call-ptr g_ogreRoot getCompositorManager2))
(var workspaceName (const (in Ogre String)) "Main Workspace")
;; const IdString definitionNameId = workspaceName;
;; TODO: This needs initializer parameters
(var-construct backgroundColour (const (in Ogre ColourValue)) 0.2f 0.2f 0.2f)
(on-call-ptr compositorManager createBasicWorkspaceDef
workspaceName backgroundColour (call (in Ogre IdString)))
(on-call-ptr compositorManager addWorkspace
g_sceneManager (on-call-ptr g_window getTexture) camera workspaceName true)
(on-call (call (in Ogre ResourceGroupManager getSingleton)) addResourceLocation
"data/Models" "FileSystem" "Models")
(on-call (call (in Ogre ResourceGroupManager getSingleton)) addResourceLocation
"data/Materials" "FileSystem" "Materials")
;; (call (in Ogre WindowEventUtilities addWindowEventListener)
;; g_window (addr g_myWindowEventListener))
(set g_graphicsIntialized true)
(return true))
(defun OgreShutdown ()
;; (call (in Ogre WindowEventUtilities removeWindowEventListener)
;; g_window (addr g_myWindowEventListener))
(OGRE_DELETE g_ogreRoot)
(set g_ogreRoot null))
(defun ogreGetSceneManager (&return (* (in Ogre SceneManager)))
(return g_sceneManager))
(defgenerator ogre-new ()
(destructure-arguments expression-index)
(addStringOutput (field output source) "OGRE_NEW" StringOutMod_SpaceAfter
(addr (at startTokenIndex tokens)))
(var expression-context EvaluatorContext context)
(set (field expression-context scope) EvaluatorScope_ExpressionsOnly)
(unless (= (EvaluateGenerate_Recursive environment expression-context
tokens expression-index output)
0)
(return false))
(return true))
;; Given
;; (var-construct name type constructor-arguments)
;; Output
;; type name(constructor-arguments);
(defgenerator var-construct ()
(var constructor-var-statement (const ([] CStatementOperation))
(array
(array TypeNoArray null 2)
(array Keyword " " -1)
(array Expression null 1)
(array OpenParen null -1)
(array ExpressionList null 3)
(array CloseParen null -1)
(array SmartEndStatement null -1)))
(return (CStatementOutput environment context tokens startTokenIndex
constructor-var-statement (array-size constructor-var-statement)
output)))

+ 0
- 325
src/OgreInitialize.cpp View File

@ -1,325 +0,0 @@
#include <stdio.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#include "OgreArchiveManager.h"
#include "OgreCamera.h"
#include "OgreConfigFile.h"
#include "OgreRoot.h"
#include "OgreWindow.h"
#include "OgreHlmsManager.h"
#include "OgreHlmsPbs.h"
#include "OgreHlmsUnlit.h"
#include "OgreItem.h"
#include "OgreMesh.h"
#include "OgreMesh2.h"
#include "OgreMeshManager.h"
#include "OgreMeshManager2.h"
#include "Compositor/OgreCompositorManager2.h"
#include "OgreWindowEventUtilities.h"
#pragma GCC diagnostic pop
Ogre::Root* g_ogreRoot = nullptr;
static Ogre::SceneManager* g_sceneManager = nullptr;
static Ogre::Window* g_window = nullptr;
bool g_graphicsIntialized = false;
bool g_ogreWindowShouldQuit = false;
class MyWindowEventListener : public Ogre::WindowEventListener
{
public:
virtual void windowClosed(Ogre::Window* window)
{
g_ogreWindowShouldQuit = true;
}
};
MyWindowEventListener g_myWindowEventListener;
static void registerHlms(void)
{
using namespace Ogre;
String resourcePath = "data/";
ConfigFile cf;
cf.load(resourcePath + "resources2.cfg");
String rootHlmsFolder = resourcePath + cf.getSetting("DoNotUseAsResource", "Hlms", "");
if (rootHlmsFolder.empty())
rootHlmsFolder = "./";
else if (*(rootHlmsFolder.end() - 1) != '/')
rootHlmsFolder += "/";
// At this point rootHlmsFolder should be a valid path to the Hlms data folder
HlmsUnlit* hlmsUnlit = 0;
HlmsPbs* hlmsPbs = 0;
// For retrieval of the paths to the different folders needed
String mainFolderPath;
StringVector libraryFoldersPaths;
StringVector::const_iterator libraryFolderPathIt;
StringVector::const_iterator libraryFolderPathEn;
ArchiveManager& archiveManager = ArchiveManager::getSingleton();
{
// Create & Register HlmsUnlit
// Get the path to all the subdirectories used by HlmsUnlit
HlmsUnlit::getDefaultPaths(mainFolderPath, libraryFoldersPaths);
Archive* archiveUnlit =
archiveManager.load(rootHlmsFolder + mainFolderPath, "FileSystem", true);
ArchiveVec archiveUnlitLibraryFolders;
libraryFolderPathIt = libraryFoldersPaths.begin();
libraryFolderPathEn = libraryFoldersPaths.end();
while (libraryFolderPathIt != libraryFolderPathEn)
{
Archive* archiveLibrary =
archiveManager.load(rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true);
archiveUnlitLibraryFolders.push_back(archiveLibrary);
++libraryFolderPathIt;
}
// Create and register the unlit Hlms
hlmsUnlit = OGRE_NEW HlmsUnlit(archiveUnlit, &archiveUnlitLibraryFolders);
Root::getSingleton().getHlmsManager()->registerHlms(hlmsUnlit);
}
{
// Create & Register HlmsPbs
// Do the same for HlmsPbs:
HlmsPbs::getDefaultPaths(mainFolderPath, libraryFoldersPaths);
Archive* archivePbs =
archiveManager.load(rootHlmsFolder + mainFolderPath, "FileSystem", true);
// Get the library archive(s)
ArchiveVec archivePbsLibraryFolders;
libraryFolderPathIt = libraryFoldersPaths.begin();
libraryFolderPathEn = libraryFoldersPaths.end();
while (libraryFolderPathIt != libraryFolderPathEn)
{
Archive* archiveLibrary =
archiveManager.load(rootHlmsFolder + *libraryFolderPathIt, "FileSystem", true);
archivePbsLibraryFolders.push_back(archiveLibrary);
++libraryFolderPathIt;
}
// Create and register
hlmsPbs = OGRE_NEW HlmsPbs(archivePbs, &archivePbsLibraryFolders);
Root::getSingleton().getHlmsManager()->registerHlms(hlmsPbs);
}
RenderSystem* renderSystem = Root::getSingletonPtr()->getRenderSystem();
if (renderSystem->getName() == "Direct3D11 Rendering Subsystem")
{
// Set lower limits 512kb instead of the default 4MB per Hlms in D3D 11.0
// and below to avoid saturating AMD's discard limit (8MB) or
// saturate the PCIE bus in some low end machines.
bool supportsNoOverwriteOnTextureBuffers;
renderSystem->getCustomAttribute("MapNoOverwriteOnDynamicBufferSRV",
&supportsNoOverwriteOnTextureBuffers);
if (!supportsNoOverwriteOnTextureBuffers)
{
hlmsPbs->setTextureBufferDefaultSize(512 * 1024);
hlmsUnlit->setTextureBufferDefaultSize(512 * 1024);
}
}
}
bool OgreInitialize(bool useCurrentWindow)
{
using namespace Ogre;
const String pluginsFolder = "./data/";
const String writeAccessFolder = "./output/";
#ifndef OGRE_STATIC_LIB
#if OGRE_DEBUG_MODE
const char* pluginsFile = "plugins_d.cfg";
#else
const char* pluginsFile = "plugins.cfg";
#endif
#endif
g_ogreRoot = OGRE_NEW Root(pluginsFolder + pluginsFile, //
writeAccessFolder + "ogre.cfg", //
writeAccessFolder + "Ogre.log");
// This allows the user to configure the graphics. It's damn annoying during dev though
// TODO: Make this return false and quit the app
// if (!g_ogreRoot->showConfigDialog())
// return false;
// Initialize Root
RenderSystem* renderSystem = g_ogreRoot->getRenderSystemByName("OpenGL 3+ Rendering Subsystem");
if (!renderSystem)
{
printf("Render system not found!\n");
return false;
}
// renderSystem->setConfigOption("Display Frequency", "N/A");
renderSystem->setConfigOption("Full Screen", "No");
// renderSystem->setConfigOption("VSync", "Yes");
renderSystem->setConfigOption("Video Mode", "1920 x 1080");
renderSystem->setConfigOption("sRGB Gamma Conversion", "Yes");
g_ogreRoot->setRenderSystem(renderSystem);
g_window = g_ogreRoot->initialise(/*autoCreateWindow=*/!useCurrentWindow, "GameLib");
// Use the already existing window
// See http://wiki.ogre3d.org/Using+SDL+Input (that actually didn't work 100%)
if (useCurrentWindow)
{
Ogre::NameValuePairList windowSettings;
// TODO: There is a scary comment about using this option in GLXWindow::create(). It may
// cause problems later. The documentation for this stuff is sorely lacking
windowSettings["currentGLDrawable"] = String("True");
windowSettings["currentGLContext"] = String("True");
int winWidth = 1920;
int winHeight = 1080;
g_window = g_ogreRoot->createRenderWindow("GameLib", winWidth, winHeight,
/*fullscreen=*/false, &windowSettings);
// renderWindow->setVisible(true);
}
registerHlms();
// Create SceneManager
const size_t numThreads = 1u;
g_sceneManager = g_ogreRoot->createSceneManager(ST_GENERIC, numThreads, "SceneManager");
// Create & setup camera
Camera* camera = g_sceneManager->createCamera("Main Camera");
// Position it at 500 in Z direction
camera->setPosition(Vector3(0, 5, 15));
// Look back along -Z
camera->lookAt(Vector3(0, 0, 0));
camera->setNearClipDistance(0.2f);
camera->setFarClipDistance(1000.0f);
camera->setAutoAspectRatio(true);
// Setup a basic compositor with a blue clear colour
CompositorManager2* compositorManager = g_ogreRoot->getCompositorManager2();
const String workspaceName("Main Workspace");
// const IdString definitionNameId = workspaceName;
const ColourValue backgroundColour(0.2f, 0.4f, 0.6f);
compositorManager->createBasicWorkspaceDef(workspaceName, backgroundColour, IdString());
compositorManager->addWorkspace(g_sceneManager, g_window->getTexture(), camera, workspaceName,
true);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("data/Models", "FileSystem",
"Models");
Ogre::WindowEventUtilities::addWindowEventListener(g_window, &g_myWindowEventListener);
g_graphicsIntialized = true;
return true;
}
bool OgreInitializeSDL()
{
using namespace Ogre;
const String pluginsFolder = "./data/";
const String writeAccessFolder = "./output/";
#ifndef OGRE_STATIC_LIB
#if OGRE_DEBUG_MODE
const char* pluginsFile = "plugins_d.cfg";
#else
const char* pluginsFile = "plugins.cfg";
#endif
#endif
g_ogreRoot = OGRE_NEW Root(pluginsFolder + pluginsFile, //
writeAccessFolder + "ogre.cfg", //
writeAccessFolder + "Ogre.log");
// This allows the user to configure the graphics. It's damn annoying during dev though
// TODO: Make this return false and quit the app
// if (!g_ogreRoot->showConfigDialog())
// return false;
// Initialize Root
RenderSystem* renderSystem = g_ogreRoot->getRenderSystemByName("OpenGL 3+ Rendering Subsystem");
if (!renderSystem)
{
printf("Render system not found!\n");
return false;
}
// renderSystem->setConfigOption("Display Frequency", "N/A");
renderSystem->setConfigOption("Full Screen", "No");
// renderSystem->setConfigOption("VSync", "Yes");
renderSystem->setConfigOption("Video Mode", "1920 x 1080");
renderSystem->setConfigOption("sRGB Gamma Conversion", "Yes");
g_ogreRoot->setRenderSystem(renderSystem);
g_window = g_ogreRoot->initialise(/*autoCreateWindow=*/false, "GameLib");
// Use the already existing window
// See http://wiki.ogre3d.org/Using+SDL+Input
{
Ogre::NameValuePairList windowSettings;
// TODO: There is a scary comment about using this option in GLXWindow::create(). It may
// cause problems later. The documentation for this stuff is sorely lacking
windowSettings["currentGLDrawable"] = String("True");
windowSettings["currentGLContext"] = String("True");
int winWidth = 1920;
int winHeight = 1080;
g_window = g_ogreRoot->createRenderWindow("GameLib", winWidth, winHeight,
/*fullscreen=*/false, &windowSettings);
// renderWindow->setVisible(true);
}
registerHlms();
// Create SceneManager
const size_t numThreads = 1u;
g_sceneManager = g_ogreRoot->createSceneManager(ST_GENERIC, numThreads, "SceneManager");
// Create & setup camera
Camera* camera = g_sceneManager->createCamera("Main Camera");
// Position it at 500 in Z direction
camera->setPosition(Vector3(0, 5, 15));
// Look back along -Z
camera->lookAt(Vector3(0, 0, 0));
camera->setNearClipDistance(0.2f);
camera->setFarClipDistance(1000.0f);
camera->setAutoAspectRatio(true);
// Setup a basic compositor with a blue clear colour
CompositorManager2* compositorManager = g_ogreRoot->getCompositorManager2();
const String workspaceName("Main Workspace");
// const IdString definitionNameId = workspaceName;
const ColourValue backgroundColour(0.2f, 0.4f, 0.6f);
compositorManager->createBasicWorkspaceDef(workspaceName, backgroundColour, IdString());
compositorManager->addWorkspace(g_sceneManager, g_window->getTexture(), camera, workspaceName,
true);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("data/Models", "FileSystem",
"Models");
Ogre::WindowEventUtilities::addWindowEventListener(g_window, &g_myWindowEventListener);
g_graphicsIntialized = true;
return true;
}
void OgreShutdown()
{
Ogre::WindowEventUtilities::removeWindowEventListener(g_window, &g_myWindowEventListener);
OGRE_DELETE g_ogreRoot;
g_ogreRoot = nullptr;
}
Ogre::SceneManager* ogreGetSceneManager()
{
return g_sceneManager;
}

+ 24
- 0
test/data/Materials/Monkey_Fur.material View File

@ -0,0 +1,24 @@
// Monkey_Fur generated by blender2ogre 2020-10-15 18:57:37.105310
material Monkey_Fur {
receive_shadows on
technique {
pass {
diffuse 0.208633 0.074452 0.015482 1.0
specular 0.488345 0.482978 0.480619 1.0 64.0
alpha_to_coverage off
colour_write on
depth_check on
depth_func less_equal
illumination_stage
light_clip_planes off
light_scissor off
normalise_normals off
polygon_mode solid
scene_blend_op add
shading gouraud
transparent_sorting on
}
}
}

BIN
test/data/Models/Suzanne.mesh View File


+ 1
- 1
test/src/OgreApp.cake View File

@ -1,6 +1,6 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(import "src/OgreCore.cake")
(import "src/Ogre.cake")
;; TODO: Should this happen automatically, because import automatically adds current working dir?
;; Should it add working dir?
(add-c-search-directory ".")


+ 1
- 1
test/src/SDLOgreApp.cake View File

@ -1,7 +1,7 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(set-cakelisp-option executable-output "test/SDLOgreApp")
(import "src/OgreCore.cake"
(import "src/Ogre.cake"
"src/SDL.cake")
;; TODO: Should this happen automatically, because import automatically adds current working dir?
;; Should it add working dir?


+ 2
- 1
test/src/VocalGame.cake View File

@ -1,7 +1,7 @@
(set-cakelisp-option cakelisp-src-dir "Dependencies/cakelisp/src")
(set-cakelisp-option executable-output "test/VocalGame")
(import "src/OgreCore.cake"
(import "src/Ogre.cake"
"src/SDL.cake"
&comptime-only "Dependencies/cakelisp/runtime/Macros.cake")
;; TODO: Should this happen automatically, because import automatically adds current working dir?
@ -13,6 +13,7 @@
;; TODO: Somehow inherit this from SDL.cake?
(module-use-sdl-build-options)
;; These are read and written to from different threads (currently, without locking)
(var audio-is-recording bool false)
(var audio-input-buffer ([] 44100 Uint8) (array 0))
(var audio-input-write-head int 0)


Loading…
Cancel
Save