Beispiel #1
0
void GlBackend::initialize() {
    glewExperimental = true;      //TODO: remove this once GLEW stops being retarded after an update
    if(glewInit() != GLEW_OK) {
        LOG_FATAL_ERROR("Glew failed to initialize");
    }

    //glClearColor(0.5f, 0.5f, 0.5f, 1.0f);

    //initialize the GL state vars
    //glGetIntegerv(GL_CURRENT_PROGRAM, (GLint *)&m_currentProgram);

    //load the temporary font shader
    /*{
        std::vector<RefCountPtr<illGraphics::Shader> > shaders;

        illGraphics::Shader * shader = new illGraphics::Shader();
        shader->loadInternal(this, "shaders/tempFont.vert", GL_VERTEX_SHADER, "");

        shaders.push_back(RefCountPtr<illGraphics::Shader>(shader));

        shader = new illGraphics::Shader();
        shader->loadInternal(this, "shaders/tempFont.frag", GL_FRAGMENT_SHADER, "");

        shaders.push_back(RefCountPtr<illGraphics::Shader>(shader));

        m_debugShaderLoader = new illGraphics::ShaderProgramLoader(this, NULL);
        m_fontShader.loadInternal(m_debugShaderLoader, shaders);
    }*/
}
Beispiel #2
0
illFileSystem::File * StdioFileSystem::openAppend(const char * path) const {
    FILE* file;

    if((file = fopen(path, "ab")) == NULL) {
        LOG_FATAL_ERROR("Failed to open file %s for appending.", path);
    }

    return new StdioFile(file, illFileSystem::File::State::ST_APPEND, path);
}
Beispiel #3
0
illFileSystem::File * StdioFileSystem::openWrite(const char * path) const {
    FILE* file;

    if((file = fopen(path, "wb")) == NULL) {
        LOG_FATAL_ERROR("Failed to open file %s for writing.", path);
    }

    return new StdioFile(file, illFileSystem::File::State::ST_WRITE, path);
}
Beispiel #4
0
void Material::unload() {
    if(m_state == RES_LOADING) {
        LOG_FATAL_ERROR("Attempting to unload material while it's loading");
    }

    if(m_state == RES_UNINITIALIZED || m_state == RES_UNLOADED) {
        return;
    }

	m_diffuseTexture.reset();
	m_specularTexture.reset();
	m_emissiveTexture.reset();
	m_normalTexture.reset();

	m_shaderProgram.reset();

    m_state = RES_UNLOADED;
}
CAndroidWindow::CAndroidWindow(SEngineConf conf,IEventListener* event_proc):
    ready(false),
    noerror(true),
    exit(false),
    EventHandler(event_proc)
{
    setObjectName("CAndroidWindow");
    LOG_ENGINE_DEBUG("CAndroidWindow() begin\n");

    if(conf.ExternalWindowID)
    {
        AndroidWindow = this;

        AndroidAPP = conf.ExternalWindowID;

        AndroidAPP->onAppCmd = engine_handle_cmd;
    }
    else
    {
        noerror = false;
        LOG_FATAL_ERROR("ExternalWindowID is NULL\n");
    }
    LOG_ENGINE_DEBUG("CAndroidWindow() end\n");
}
void FixedStepController::appLoop() {      
    //if the application controller isn't in the expected state error
    if (m_state != APPST_INITIALIZED) {
        LOG_FATAL_ERROR("Application in unexpected state.");
    }

    m_state = APPST_RUNNING;

    float timeAccumulator = 0.0f;
    int32_t lastLoopTime = SDL_GetTicks();

    while (m_state == APPST_RUNNING) {
        //poll input events from the game's window
        m_engine->m_window->pollEvents();

        //compute time since last game loop
        int32_t currentLoopTime = SDL_GetTicks();
        int32_t milliseconds = currentLoopTime - lastLoopTime;
        lastLoopTime = currentLoopTime;
        timeAccumulator += milliseconds;
        
        int steps = 0;

        float seconds = (float) milliseconds / 1000.0f;

        if(m_engine->m_showingFps && seconds > 0.0f) {
            m_fpsGraph.addDataPoint(1.0f / seconds);
        }

        //update developer console
        m_console->update(seconds);

        //run the game loop with a fixed step
        while(timeAccumulator > STEP_SIZE && steps++ < MAX_STEPS) {
            timeAccumulator -= STEP_SIZE;

            m_gameController->update(STEP_SIZE / 1000.0f);
        }
        
        /////////////////////
        //update sound
        m_gameController->updateSound(seconds);

        /////////////////////
        //draw screen
        m_engine->m_window->beginFrame();
        m_engine->m_graphicsBackend->beginFrame();
                
        m_gameController->render();
                
        m_console->render();        
        
        if(m_engine->m_showingFps) {
            renderFpsGraph();
        }

        m_engine->m_graphicsBackend->endFrame();
        m_engine->m_window->endFrame();

        //force delay 1 ms to avoid precision issues
        SDL_Delay(1);
    }
}
CNovaEngine::CNovaEngine(SEngineConf engine_conf):
    m_EventManager(nullptr),
    m_Window(nullptr),
    m_Renderer(nullptr),
    m_FileSystem(nullptr),
    m_ResourceManager(nullptr),
	m_GeometryManager(nullptr),
    m_SceneManager(nullptr),
    m_GUIManager(nullptr),
    m_PerformanceCounter(nullptr),
    m_noerror(true),
    m_exit(false)
{

    LOG_INFO("NovaEngine %s \"%s\" [Builded : %s - %s] \n",NOVAENGINE_FULLVERSION_STRING,NOVAENGINE_STATUS,__TIME__,__DATE__);

#ifdef NE_DEBUG
    log::CLogger::get()->set_log_level(log::ELL_ENGINE_DEBUG);
#else
    log::CLogger::get()->set_log_level(engine_conf.LogLevel);
#endif // NE_DEBUG
//------------------------------------------
    m_EventManager       = new CEventManager();
    m_PerformanceCounter = new CPerformanceCounter();
//------------------------------------------

#if defined(NE_WINDOW_WIN32)
    m_Window = new window::CWin32Window(engine_conf,m_EventManager); //Создание окна для Windows
#elif defined(NE_WINDOW_ANDROID)
    Window = nullptr; //!< Android support removed temporary due rewrites of window class(again)
    //Over and over
    //Over and over
    //I rewrite this piece of shiiiit...
#elif defined(NE_WINDOW_X11)
#error "Oops missing code"
#else
#error "No window system selected"
#endif
    if(m_Window == nullptr || !m_Window->isOk())
    {
        LOG_FATAL_ERROR("Cannot create window class\n");
        m_noerror = false;
        return;
    }


    switch(engine_conf.Renderer)
    {
    case renderer::ERT_OPENGL:
#if   defined(NE_OPENGL_RENDERER)
		{
			renderer::COpenGLRenderer* OpenGLRenderer = new renderer::COpenGLRenderer(m_PerformanceCounter, m_Window, engine_conf);
			m_EventManager->registerEventListener((IEventListener*)OpenGLRenderer, EET_WINDOW_EVENT, 1);
			m_Renderer = OpenGLRenderer;
		}
#elif defined(NE_OPENGLES1_RENDERER)
        Renderer = new renderer::COpenGLES1Renderer(Window,engine_conf);
#else
        LOG_FATAL_ERROR("OpenGL renderer not compiled in current engine version\n");
#endif // NE_OPENGL_RENDERER
        break;
    default:
        LOG_FATAL_ERROR("Unknown renderer selected\n");
    }
    if(m_Renderer == nullptr || !m_Renderer->isOk())
    {
        LOG_FATAL_ERROR("Cannot create renderer class\n");
        m_noerror = false;
        return;
    }

    m_FileSystem      = new io::CFileSystem();
    m_ResourceManager = new CResourceManager(m_FileSystem);
    m_GeometryManager = new CGeometryManager(m_ResourceManager);
    m_SceneManager    = new scene::CSceneManager(m_Renderer,m_EventManager);
    m_GUIManager      = new gui::CGUIManager(m_Renderer,m_EventManager);
}