@@ -79,13 +79,19 @@ GLuint RenderManager::CreateMesh(std::vector<Vertex> p_vertices, bool p_async)
return r_positionBuffer;
}

GLuint RenderManager::CreateTexture(void * p_textureData, int p_numBytes)
GLuint RenderManager::CreateTexture(void * p_textureData, int p_numBytes, bool p_async)
{
// Magic soil thing that's really untested

if (p_async)
SDLManager::Get()->SetLoadContext(true);
GLuint r_textureHandle = SOIL_load_OGL_texture_from_memory(
reinterpret_cast<unsigned char*>(p_textureData),
p_numBytes,
SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_COMPRESS_TO_DXT);
// Not sure why this is important, but it is
glFinish();

//// Code to manually create an empty texture. Dumping this here sounds like a bood idea
//glGenTextures(1, &r_textureHandle);
////glActiveTexture(GL_TEXTURE0); // Might be necessary
@@ -94,7 +100,7 @@ GLuint RenderManager::CreateTexture(void * p_textureData, int p_numBytes)
////glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Might be needed
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, p_texWidth, p_texHeight, 0, GL_RGBA, GL_FLOAT, NULL); // Last parameter is the data
//
////glBindImageTexture(0, r_textureHandle, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F); // Might be needed
//glBindImageTexture(0, r_textureHandle, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F); // Might be needed
return r_textureHandle;
}

@@ -199,6 +205,7 @@ void RenderManager::Render()




//// HARD CODED SHIT BELOW! Draws a silly triangle
//GLuint mvpHandle = glGetUniformLocation(m_shaderHandler->GetShaderProgram(ShaderProgram::DefaultShader), "MVP");
//glUniformMatrix4fv(mvpHandle, 1, GL_FALSE, &vp[0][0]);
@@ -39,7 +39,7 @@ class RenderManager
/**
Takes the provided data and turns it into a
texture on the GPU. Returns GLuint handle*/
GLuint CreateTexture(void* p_textureData, int p_numbBytes);
GLuint CreateTexture(void* p_textureData, int p_numbBytes, bool p_async);

/**
Loads the specified file and converts it to