Giter VIP home page Giter VIP logo

mogre's Introduction

Hey! I am Amer Koleci, my github id is `amerkoleci`

I'm a self-taught, passionate software developer from Italy

Amer streak Amer top langs

Amer's github activity graph

  • ๐Ÿ”ญ Iโ€™m currently working as senior software engineer using C#/VB .NET and .NET in general writing WMS software.
  • โค๏ธ I love open source and work on personal projects whether possible, I enjoy contributing to other projects and share opinions with other people.
  • ๐ŸŒŸ I like to write game engine code and explore the different graphics APIs out there (Direct3D12, Vulkan, Metal or OpenGL). Therefore, I have created several projects to abstract the graphics APIs to make it easier to do graphics programming, which is where my main focus is. I love learning and read about new rendering techniques and try to implement them.
  • ๐Ÿ’ฌ If you have any question feel free to contact me and I will gladly reply.
  • ๐Ÿค” If you like to join my open source project feel free to do so by submitting PR or opening issues.
  • โšก Consider SPONSORING me to help me out reach my goals sooner.

If you are curious, I suggest you check out the following repositories:

mogre's People

Contributors

amerkoleci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mogre's Issues

A simpler way to auto convert from a managed System::String^ to an unmanaged Ogre::String

Hello there @amerkoleci
I found a simpler way to auto convert from a managed System::String^ to an unmanaged Ogre::String

Let's see the adapter class first:

#pragma once

// SmartString.h

#include <OgrePrerequisites.h>
#include <OgreCommon.h>

using namespace System::Runtime::InteropServices;

/// <summary>
/// auto convert from managed System::String^ to unmanaged Ogre::String
/// </summary>
class SmartString
{
public:

    SmartString(System::String^ str)
    {
        if (!System::String::IsNullOrEmpty(str))
        {
            SmartString::_InitNativeStringWithCLRString_(_str, str);
        }
    }

    virtual ~SmartString() {}

    /// <summary>
    /// auto convert to Ogre::String
    /// </summary>
    /// <returns>Ogre::String</returns>    
    operator Ogre::String()
    {
        return _str;
    }

    const char* c_str()
    {
        return _str.c_str();
    }

protected:

    Ogre::String _str;

    // wrapper func
    static void _InitNativeStringWithCLRString_(Ogre::String& ostr, System::String^ mstr)
    {
        if (mstr == nullptr)
            throw gcnew System::NullReferenceException("A null string cannot be converted to an Ogre string.");

        System::IntPtr p_mstr = Marshal::StringToHGlobalAnsi(mstr);
        ostr = static_cast<char*>(p_mstr.ToPointer());
        Marshal::FreeHGlobal(p_mstr);
    }
};

Now with the SmartString class, we can convert a managed System::String^ to an unmanaged Ogre::String like this:

SmartString(nstr);

And an example like this:

// Original code from MogreRoot.cpp:

Root::Root(String^ pluginFileName, String^ configFileName, String^ logFileName)
{
	_createdByCLR = true;
	DECLARE_NATIVE_STRING(o_pluginFileName, pluginFileName);
	DECLARE_NATIVE_STRING(o_configFileName, configFileName);
	DECLARE_NATIVE_STRING(o_logFileName, logFileName);
	_native = new G3D::Root(o_pluginFileName, o_configFileName, o_logFileName);
}

// New code:

Root::Root(String^ pluginFileName, String^ configFileName, String^ logFileName)
{
	_createdByCLR = true;
	_native = new G3D::Root(SmartString(pluginFileName), SmartString(configFileName), SmartString(logFileName));
}

I wish this can help, thanks!

Return of Mogre

Hi, I've updated Premake5 and included the vs2019.bat file I'm trying to compile the project.

You have not updated but have not withdrawn the project. Do you have any plans to touch it again?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.