<commit_before>#include "RTEngine.hpp"
#include "Ray.hpp"
#include "Shape.hpp"
#include "Material.hpp"
#include "Sphere.hpp"
#include <iostream>
#include <algorithm>

namespace RealRT
{
    /*
      Window

      Utility structure that defines the
      start x,y for a window on the
      screen. This windows size is
      usually determined by RTEngine::DefaultWindowSize,
      however when the screensize is not a multiple of 10,
      the size can be smaller to account for the edges. Sizes
      for both axes should always be checked.

    */
    class Window
    {
        int left;
        int top;

        int right;
        int bottom;
    };

    /*
        TRACENODE

        Utility structure, represents a
        node in the trace tree, this tree is kept implicitly
        on the stack

    */
    class TraceNode
    {
        Vector3D color;
        Vector3D shapeColor;

        Ray r;
        double refrIndex;
        double multiplier;
        bool eval;

        int	depth;

        TraceNode *parent = nullptr;
    };
}

using namespace RealRT;

std::shared_ptr<RTEngine> RTEngine::Instantiate(int width, int height)
{
	//before instantiation, make sure there isnt already one
	//
	if(_Instance == nullptr)
	{
		_Instance.reset(new RTEngine(width, height));
	}
	else
	{
		if(width != _Instance->_ScreenWidth)
		{
			_Instance->_Resize(width,height);
		}
	}

	return _Instance;
}

RTEngine::RTEngine(int width,int height)
	: _MaxAsyncOperations(4)
{
	_Resize(width, height);
}

void RTEngine::_ScreenToLogical(const int i, const int j, float &x, float &y) const
{
    float widthScalar = float(LogicalWidth) / float(_ScreenWidth);
    float heightScalar = float(LogicalHeight) / float(_ScreenHeight);

    x = (i * widthScalar) - (LogicalWidth / 2.f);
    y = (j * heightScalar) - (LogicalHeight / 2.f);
}

void RTEngine::CalculateScene()<commit_msg>Added initialization for _Instance and implementation for getting the screen pointer<commit_after>#include "RTEngine.hpp"
#include "Ray.hpp"
#include "Shape.hpp"
#include "Material.hpp"
#include "Sphere.hpp"
#include <iostream>
#include <algorithm>

namespace RealRT
{
    /*
      Window

      Utility structure that defines the
      start x,y for a window on the
      screen. This windows size is
      usually determined by RTEngine::DefaultWindowSize,
      however when the screensize is not a multiple of 10,
      the size can be smaller to account for the edges. Sizes
      for both axes should always be checked.

    */
    class Window
    {
        int left;
        int top;

        int right;
        int bottom;
    };

    /*
        TRACENODE

        Utility structure, represents a
        node in the trace tree, this tree is kept implicitly
        on the stack

    */
    class TraceNode
    {
        Vector3D color;
        Vector3D shapeColor;

        Ray r;
        double refrIndex;
        double multiplier;
        bool eval;

        int	depth;

        TraceNode *parent = nullptr;
    };
}

using namespace RealRT;

std::shared_ptr<RTEngine> RTEngine::_Instance(nullptr);

std::shared_ptr<RTEngine> RTEngine::Instantiate(int width, int height)
{
	//before instantiation, make sure there isnt already one
	//
	if(_Instance == nullptr)
	{
		_Instance.reset(new RTEngine(width, height));
	}
	else
	{
		if(width != _Instance->_ScreenWidth)
		{
			_Instance->_Resize(width,height);
		}
	}

	return _Instance;
}

RTEngine::RTEngine(int width,int height)
	: _MaxAsyncOperations(4)
{
	_Resize(width, height);
}

void RTEngine::_ScreenToLogical(const int i, const int j, float &x, float &y) const
{
    float widthScalar = float(LogicalWidth) / float(_ScreenWidth);
    float heightScalar = float(LogicalHeight) / float(_ScreenHeight);

    x = (i * widthScalar) - (LogicalWidth / 2.f);
    y = (j * heightScalar) - (LogicalHeight / 2.f);
}

unsigned char *RTEngine::Screen(void) const
{
    return _Screen.get();
}

void RTEngine::CalculateScene()
{'fraction_non_alphanumeric': 0.09557522123893805, 'fraction_numerical': 0.0035398230088495575, 'mean_word_length': 2.746212121212121, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1655622', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1220, 'n_words': 373}