<commit_before>//
//  CRendererOGL1_5.h
//  OpenJam
//
//  Created by <NAME>
//  Copyright (c) 2014 yev. All rights reserved.
//
#if defined(RENDER_OGL1_5)

#include "CRendererOGL1_5.h"

#include "CVertexBufferOGL1_5.h"
#include "CIndexBufferOGL1_5.h"
#include "CMaterialOGL1_5.h"
#include "CTextureOGL1_5.h"
#include "CMeshOGL1_5.h"
#include "CShaderOGL1_5.h"
#include "CShaderProgramOGL1_5.h"
#include "CFrameBufferOGL1_5.h"

using namespace jam;

// *****************************************************************************
// Constants
// *****************************************************************************

// *****************************************************************************
// Public Methods
// *****************************************************************************

INL int CovertPrimitiveType(IMaterial::PrimitiveTypes type);

CRendererOGL1_5::CRendererOGL1_5(IRenderViewPtr renderView)
: m_RenderView(renderView)
{

}

CRendererOGL1_5::~CRendererOGL1_5()
{

}

IRenderViewPtr CRendererOGL1_5::RenderView() const
{
    return m_RenderView;
}

IVertexBufferPtr CRendererOGL1_5::CreatVertexBuffer()
{
    IVertexBufferPtr vertexBuffer(new CVertexBufferOGL1_5());
    return vertexBuffer;
}

IIndexBufferPtr CRendererOGL1_5::CreateIndexBuffer()
{
    IIndexBufferPtr indexBuffer(new CIndexBufferOGL1_5());
    return indexBuffer;
}

ITexturePtr CRendererOGL1_5::CreateTexture()
{
    ITexturePtr texture(new CTextureOGL1_5());
    return texture;
}

IMaterialPtr CRendererOGL1_5::CreateMaterial()
{
    IMaterialPtr material(new CMaterialOGL1_5());
    return material;
}

IMeshPtr CRendererOGL1_5::CreateMesh()
{
    IMeshPtr mesh(new CMeshOGL1_5());
    return mesh;
}

IShaderPtr CRendererOGL1_5::CreateShader()
{
    IShaderPtr shader(new CShaderOGL1_5());
    return shader;
}

IShaderProgramPtr CRendererOGL1_5::CreateShaderProgram()
{
    IShaderProgramPtr shaderProgram(new CShaderProgramOGL1_5());
    return shaderProgram;
}

IRenderTargetPtr CRendererOGL1_5::CreateRenderTarget(unsigned int width, unsigned int height)
{
    IRenderTargetPtr renderTarget(new CFrameBufferOGL1_5(width, height));
    return renderTarget;
}

void CRendererOGL1_5::Draw(IMeshPtr mesh, IMaterialPtr material, IShaderProgramPtr shader)
{
    if (!mesh ||
        !material)
    {
        return;
    }
    
    const IShaderProgram::TUniMatrix4Float& uniforms = shader->UniformsMatrix4x4f();
    IShaderProgram::TUniMatrix4Float::const_iterator it = uniforms.find(shader->ProjectionMatrix());
    if (it != uniforms.end())
    {
        glMatrixMode(GL_PROJECTION);        
        glLoadTransposeMatrixf(glm::value_ptr(it->second));
    }   // TODO: load identity for other case
    
    it = uniforms.find(shader->ModelMatrix());
    if (it != uniforms.end())
    {
        glMatrixMode(GL_MODELVIEW);
        glLoadTransposeMatrixf(glm::value_ptr(it->second));
    }   // TODO: load identity for other case
    
    if (mesh->IndexBuffer())
    {
        Draw(mesh->VertexBuffer(), mesh->IndexBuffer(), material);
    }<commit_msg>Fixed matrix uploading to OGL<commit_after>//
//  CRendererOGL1_5.h
//  OpenJam
//
//  Created by <NAME>
//  Copyright (c) 2014 yev. All rights reserved.
//
#if defined(RENDER_OGL1_5)

#include "CRendererOGL1_5.h"

#include "CVertexBufferOGL1_5.h"
#include "CIndexBufferOGL1_5.h"
#include "CMaterialOGL1_5.h"
#include "CTextureOGL1_5.h"
#include "CMeshOGL1_5.h"
#include "CShaderOGL1_5.h"
#include "CShaderProgramOGL1_5.h"
#include "CFrameBufferOGL1_5.h"

using namespace jam;

// *****************************************************************************
// Constants
// *****************************************************************************

// *****************************************************************************
// Public Methods
// *****************************************************************************

INL int CovertPrimitiveType(IMaterial::PrimitiveTypes type);

CRendererOGL1_5::CRendererOGL1_5(IRenderViewPtr renderView)
: m_RenderView(renderView)
{

}

CRendererOGL1_5::~CRendererOGL1_5()
{

}

IRenderViewPtr CRendererOGL1_5::RenderView() const
{
    return m_RenderView;
}

IVertexBufferPtr CRendererOGL1_5::CreatVertexBuffer()
{
    IVertexBufferPtr vertexBuffer(new CVertexBufferOGL1_5());
    return vertexBuffer;
}

IIndexBufferPtr CRendererOGL1_5::CreateIndexBuffer()
{
    IIndexBufferPtr indexBuffer(new CIndexBufferOGL1_5());
    return indexBuffer;
}

ITexturePtr CRendererOGL1_5::CreateTexture()
{
    ITexturePtr texture(new CTextureOGL1_5());
    return texture;
}

IMaterialPtr CRendererOGL1_5::CreateMaterial()
{
    IMaterialPtr material(new CMaterialOGL1_5());
    return material;
}

IMeshPtr CRendererOGL1_5::CreateMesh()
{
    IMeshPtr mesh(new CMeshOGL1_5());
    return mesh;
}

IShaderPtr CRendererOGL1_5::CreateShader()
{
    IShaderPtr shader(new CShaderOGL1_5());
    return shader;
}

IShaderProgramPtr CRendererOGL1_5::CreateShaderProgram()
{
    IShaderProgramPtr shaderProgram(new CShaderProgramOGL1_5());
    return shaderProgram;
}

IRenderTargetPtr CRendererOGL1_5::CreateRenderTarget(unsigned int width, unsigned int height)
{
    IRenderTargetPtr renderTarget(new CFrameBufferOGL1_5(width, height));
    return renderTarget;
}

void CRendererOGL1_5::Draw(IMeshPtr mesh, IMaterialPtr material, IShaderProgramPtr shader)
{
    if (!mesh ||
        !material)
    {
        return;
    }
    
    const IShaderProgram::TUniMatrix4Float& uniforms = shader->UniformsMatrix4x4f();
    IShaderProgram::TUniMatrix4Float::const_iterator it = uniforms.find(shader->ProjectionMatrix());
    if (it != uniforms.end())
    {
        glMatrixMode(GL_PROJECTION);        
        glLoadMatrixf(glm::value_ptr(it->second));
    }   // TODO: load identity for other case
    
    it = uniforms.find(shader->ModelMatrix());
    if (it != uniforms.end())
    {
        glMatrixMode(GL_MODELVIEW);
        glLoadMatrixf(glm::value_ptr(it->second));
    }   // TODO: load identity for other case
    
    if (mesh->IndexBuffer())
    {
        Draw(mesh->VertexBuffer(), mesh->IndexBuffer(), material);
    }
{'fraction_non_alphanumeric': 0.20450833061091148, 'fraction_numerical': 0.024175106174452794, 'mean_word_length': 5.032512315270936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3296377', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1994, 'n_words': 326}