Browse Source

Update Cakelisp, move a node

* Deleted commented code
SDLAttempt
Macoy Madson 3 months ago
parent
commit
a61028e0d2
5 changed files with 21 additions and 91 deletions
  1. +2
    -2
      Build_Debug.sh
  2. +1
    -1
      Dependencies/cakelisp
  3. +10
    -5
      src/OgreCore.cake
  4. +0
    -83
      src/OgreInitialize.cpp
  5. +8
    -0
      test/OgreApp.cake

+ 2
- 2
Build_Debug.sh View File

@ -1,6 +1,6 @@
#!/bin/sh
# TODO: Support compiling as a library?
# ./Dependencies/cakelisp/bin/cakelisp src/OgreCore.cake || exit $?
# TODO: Figure out how to remove clean by teaching jam about libGameLib.a (dyn link instead?)
./Dependencies/cakelisp/bin/cakelisp test/OgreApp.cake
./Dependencies/cakelisp/bin/cakelisp --verbose-processes test/OgreApp.cake

+ 1
- 1
Dependencies/cakelisp

@ -1 +1 @@
Subproject commit 9f387399030f946bd75a8f92c5ec7295b8345b70
Subproject commit 599b6c8b16cb6bbb079d37f0145feb23a22a757b

+ 10
- 5
src/OgreCore.cake View File

@ -102,7 +102,7 @@
;; TODO: Support global vs local?
(var is-global bool true)
(var output-dest (& (<> std::vector StringOutput))
(? is-global output.header output.source))
(? is-global (field output header) (field output source)))
(var end-invocation-index int (FindCloseParenTokenIndex tokens startTokenIndex))
(var start-body-index int (+ 2 startTokenIndex))
@ -148,18 +148,22 @@
(when (= close-block-index current-index)
(addLangTokenOutput output-dest StringOutMod_CloseBlock
(addr (at current-index tokens))))))
;; TODO: Support function calls so we can do this recursively
;; TODO: Support function calls so we can do this recursively?
;; (set current-index
;; (getNextArgument tokens current-index end-invocation-index))
(incr current-index))
(return true))
(defun ogre-node-set-position (node (* scene-node) x float y float z float)
(on-call-ptr (path node > node) setPosition x y z))
;;
;; Building
;;
;; TODO: Relative vs. absolute paths
(import &comptime-only "../Dependencies/cakelisp/runtime/Macros.cake")
(add-cpp-build-dependency "OgreInitialize.cpp")
(set-module-option build-time-compiler "/usr/bin/clang++")
@ -176,6 +180,7 @@
"-IDependencies/ogre-next/build/Debug/include"
"-IDependencies/ogre-next/Components/Overlay/include")
;; TODO: Automatically build Ogre if it isn't built yet, and copy necessary files
;; (defun-comptime ogre-pre-build-hook ()
;; (unless (fileExists "Dependencies/ogre-next/build/Debug/lib")
;; (printf "error: Ogre is not built yet. Please run ./BuildDependencies_Debug.sh\n")
@ -196,11 +201,11 @@
linkTimeInputs (* ProcessCommandInput) numLinkTimeInputs int
&return bool)
;; TODO: Expose this option somehow?
(var debug bool true)
(var is-debug-build bool true)
(printf "OgreCore: Adding %s link arguments\n" (? debug "debug" "release"))
(printf "OgreCore: Adding %s link arguments\n" (? is-debug-build "debug" "release"))
(if debug
(if is-debug-build
(block
(command-add-string-argument "-LDependencies/ogre-next/build/Debug/lib")
(command-add-string-argument "-lOgreHlmsPbs_d")


+ 0
- 83
src/OgreInitialize.cpp View File

@ -172,38 +172,6 @@ bool OgreInitialize()
g_ogreRoot->setRenderSystem(renderSystem);
g_window = g_ogreRoot->initialise(/*autoCreateWindow=*/true, "GameLib");
// Old bad attempt at Ogre within SFML (only party worked)
{
// Ogre::NameValuePairList windowSettings;
// unsigned long winHandle = reinterpret_cast<unsigned
// long>(win.getBase()->getSystemHandle()); #ifdef _WIN32 unsigned long winGlContext =
// reinterpret_cast<unsigned long>(wglGetCurrentContext());
// windowSettings["externalWindowHandle"] = StringConverter::toString(winHandle);
// windowSettings["externalGLContext"] = StringConverter::toString(winGlContext);
// windowSettings["externalGLControl"] = String("True");
// #else
// // Deprecated. See
// ogre-next/RenderSystems/GL3Plus/src/windowing/GLX/OgreGLXWindow.cpp:237
// // windowSettings["externalWindowHandle"] = StringConverter::toString(winHandle);
// windowSettings["parentWindowHandle"] = StringConverter::toString(winHandle);
// // sf::Context context;
// // unsigned long activeContextId = (unsigned long)context.getActiveContextId();
// windowSettings["currentGLContext"] = String("True");
// // windowSettings["currentGLContext"] = StringConverter::toString(activeContextId);
// // windowSettings["externalGLControl"] = String("True");
// #endif
// int winWidth = 1920;
// int winHeight = 1080;
// Window* window =
// // g_ogreRoot->createRenderWindow("GameLib", winWidth, winHeight, true, &windowSettings);
// g_ogreRoot->createRenderWindow("GameLib", winWidth, winHeight, true);
// g_window->_setVisible(true);
}
registerHlms();
// Create SceneManager
@ -233,57 +201,6 @@ bool OgreInitialize()
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("data/Models", "FileSystem",
"Models");
// Mesh importing
if (false)
{
Ogre::v1::MeshPtr v1Mesh;
Ogre::MeshPtr v2Mesh;
// Load the v1 mesh. Notice the v1 namespace
// Also notice the HBU_STATIC flag; since the HBU_WRITE_ONLY
// bit would prohibit us from reading the data for importing.
v1Mesh = Ogre::v1::MeshManager::getSingleton().load(
"Chassis.mesh", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC);
bool halfPosition = true;
bool halfUVs = true;
bool useQtangents = true;
// Create a v2 mesh to import to, with a different name (arbitrary).
// Import the v1 mesh to v2
v2Mesh = Ogre::MeshManager::getSingleton().createByImportingV1(
"Chassis.mesh Imported", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
v1Mesh.get(), halfPosition, halfUVs, useQtangents);
// We don't need the v1 mesh. Free CPU memory, get it out of the GPU.
// Leave it loaded if you want to use athene with v1 Entity.
v1Mesh->unload();
// Create an Item with the model we just imported.
// Notice we use the name of the imported model. We could also use the overload
// with the mesh pointer:
// item = g_sceneManager->createItem( v2Mesh, Ogre::SCENE_DYNAMIC );
Ogre::Item* item = g_sceneManager->createItem(
"Chassis.mesh Imported", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::SCENE_DYNAMIC);
// Ogre::SceneNode* rootSceneNode = g_sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC);
Ogre::SceneNode* rootSceneNode = g_sceneManager->getRootSceneNode();
if (!rootSceneNode)
{
return false;
}
// WTF - this should work, but it's almost like the root scene node's vtable is wrong
// Ogre::SceneNode* sceneNode = rootSceneNode->createChildSceneNode(Ogre::SCENE_DYNAMIC);
Ogre::SceneNode* sceneNode = static_cast<SceneNode*>(
rootSceneNode->createChild()); // rootSceneNode->createChildSceneNode();
if (!sceneNode)
{
return false;
}
sceneNode->attachObject(item);
// sceneNode->scale( 0.1f, 0.1f, 0.1f );
}
Ogre::WindowEventUtilities::addWindowEventListener(g_window, &g_myWindowEventListener);
g_graphicsIntialized = true;


+ 8
- 0
test/OgreApp.cake View File

@ -13,11 +13,19 @@
(var exit-reason (* (const char)) nullptr)
(var x float 0.f)
(var y float 0.f)
(var z float 0.f)
;; Main loop
(while true
(unless (ogre-handle-window-events)
(set exit-reason "Window closed")
(break))
(ogre-node-set-position (addr monkey-node) x y z)
(set x (+ x 0.01f))
(unless (ogre-render-frame)
(set exit-reason "Failed to render frame")
(break)))


Loading…
Cancel
Save