Topic: Maratis MCore/MEngine C++ "Hello World" Example

I was wondering if anyone had a simple C++ "Hello, World" type example that uses
MCore & MEngine?

I tried using the ManualUse example as a reference for a bare-bones
type example but I keep getting a segfault.

I need something even more basic for testing.

Any help would be great smile

Re: Maratis MCore/MEngine C++ "Hello World" Example

http://www.maratis3d.org/?p=500 <-- have you tried that example?

Re: Maratis MCore/MEngine C++ "Hello World" Example

Maybe I asked the wrong question.

Do the MEngine or MGame classes have to be subclassed
in order to be used?

Re: Maratis MCore/MEngine C++ "Hello World" Example

Looking at the example, it looks like you can inherit from MGame if you want (although it does nothing with it) however I think it's probably fairly unwise to replace MEngine as it's a singleton.

Re: Maratis MCore/MEngine C++ "Hello World" Example

ManualUse example is one of the simplest,
just initializing MCore + MEngine and loading some mesh.

What do you mean by subclassed ?

Re: Maratis MCore/MEngine C++ "Hello World" Example

anael wrote:

ManualUse example is one of the simplest,
just initializing MCore + MEngine and loading some mesh.

What do you mean by subclassed ?

In ManualUse MyGame.h you derive a new class from MGame

class MyGame : public MGame
{
public:

I was asking because with some library's there not meant to be used directly. You have to
"subclass" derive a new class from an existing one.

What I was trying to do was use Maratis' Rendering context in SFML2

 int main()
 {
     // Create the main window
     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
 
    MEngine *engine = MEngine::getInstance();
    MRenderingContext *render = engine->getRenderingContext();
    MGame *game = engine->getGame();
    
    render->setViewport(0, 0, 100, 100);

But when I initialize my MGame pointer *game I get a segfault.

Re: Maratis MCore/MEngine C++ "Hello World" Example

There is no game by default,
engine->getGame(); will return a NULL

but MGame implement basic functionalities, so you can create one :

MGame * game = new MGame();
engine->setGame(game);

And of course, for a custom game, you can inherit MGame and customize functions you want (update, draw).

Re: Maratis MCore/MEngine C++ "Hello World" Example

I also want to know simple Hello World standalone executable, not dynamic library, and without MaratisPlayer
can it?

can I bundle MaratisPlayer source into my project?
what about the license?since MaratisPlayer use GPL not zlib/png license.


*edit
forget it, I look at ManualUse, and this is what I'm lookin for.

ohh, currently lua is used for scripting, right?
any plan to make lua as binding?so we can make game entirely with lua, just like corona big_smile

Last edited by jurgel (2012-01-17 04:05:02)

Re: Maratis MCore/MEngine C++ "Hello World" Example

Well if anyone want's to use Maratis with SFML2 here is some code to start
with. Can't see the model but I imagen that has something to do with transformations.

But the viewport is visible.

#include <SFML/Graphics.hpp>
#include <MCore.h>
#include <MEngine.h>
#include "MGLContext.h"
#include <iostream>

int main()
 {
     // Create the main window
     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

     MEngine * engine = MEngine::getInstance();

     MRenderingContext * render = new MGLContext();
     render->disableScissorTest();
     render->setViewport(0, 0, 200, 200);

     engine->setRenderingContext(render);

     MGame * game = new MGame();
     engine->setGame(game);

     // get level
     MLevel * level = new MLevel();
     engine->setLevel(level);

     if(level->getScenesNumber() == 0)
     {
         MScene * scene = level->addNewScene();

         MOCamera * camera = scene->addNewCamera();
         camera->setClearColor(MVector3(1.0f, 0.075f, 1.0f)); // set grey clear color
         camera->setPosition(MVector3(0.0f, -80.0f, 20.0f));
         camera->setEulerRotation(MVector3(90.0f, 0.0f, 0.0f));

         MMeshRef * meshRef = level->loadMesh("box.mesh");
         MOEntity * box1 = scene->addNewEntity(meshRef);

         box1->setPosition(MVector3(70, 65, 0));
         box1->setScale(MVector3(4, 4, 0.2f));

         MOLight * light = scene->addNewLight();
         light->setPosition(MVector3(0.0f, 0.0f, 100.0f));
         light->setRadius(1000.0f);
     }

     game->begin();
     // Start the game loop
     while (window.IsOpened())
     {
         // Process events
         sf::Event event;
         while (window.PollEvent(event))
         {
             // Close window : exit
             if (event.Type == sf::Event::Closed)
                 window.Close();
         }
 
         // Clear screen
         window.Clear(sf::Color(255, 255, 255 ,255));
         game->draw();
         std::cout << game->isRunning() << std::endl;
         // Update the window
         window.Display();
     }
     
     game->end();

     SAFE_DELETE(game);
     SAFE_DELETE(level);

     SAFE_DELETE(render);
     return EXIT_SUCCESS;
 }

Last edited by zester (2012-01-17 05:01:05)