Hello, I have a scene that consists of 1 player object, 1 platform, 1 enemy, and 1 background. Currently, this is how my render function looks like:



Code :
   void Sprite::Render()
    {
    	glUseProgram(m_Program);
    	glActiveTexture(GL_TEXTURE0);
 
    	// Background 
    	glBindVertexArray(m_BackgroundVAO);
    	glBindTexture(GL_TEXTURE_2D, m_Textures[1]);
    	glUniform1i(glGetUniformLocation(m_Program, "Texture1"), 0);
 
    	m_ProjectionMatrix = m_Camera.ViewToWorldMatrix();
    	m_TransformationMatrix = m_ProjectionMatrix;
    	m_TransformationMatrixLoc = glGetUniformLocation(m_Program, "TransformationMatrix");
    	glUniformMatrix4fv(m_TransformationMatrixLoc, 1, GL_FALSE, &m_TransformationMatrix[0][0]);
 
    	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
 
    	// Enemy One
    	glBindVertexArray(m_EnemyOneVAO);
    	glBindTexture(GL_TEXTURE_2D, m_Textures[2]);
    	glUniform1i(glGetUniformLocation(m_Program, "Texture3"), 0);
 
    	m_ProjectionMatrix = glm::translate(glm::mat4(), glm::vec3(EnemyOneXCoord, EnemyOneYCoord, 0.0f)) * m_Camera.ViewToWorldMatrix();
    	m_TransformationMatrix = m_ProjectionMatrix;
    	m_TransformationMatrixLoc = glGetUniformLocation(m_Program, "TransformationMatrix");
    	glUniformMatrix4fv(m_TransformationMatrixLoc, 1, GL_FALSE, &m_TransformationMatrix[0][0]);
 
    	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
 
    	// Platform One
    	glBindVertexArray(m_PlatformVAO);
    	glBindTexture(GL_TEXTURE_2D, m_Textures[3]);
    	glUniform1i(glGetUniformLocation(m_Program, "Texture4"), 0);
 
    	m_ProjectionMatrix = glm::translate(glm::mat4(), glm::vec3(0.0f, -0.5f, 0.0f)) * m_Camera.ViewToWorldMatrix();
    	m_TransformationMatrix = m_ProjectionMatrix;
    	m_TransformationMatrixLoc = glGetUniformLocation(m_Program, "TransformationMatrix");
    	glUniformMatrix4fv(m_TransformationMatrixLoc, 1, GL_FALSE, &m_TransformationMatrix[0][0]);
 
    	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
 
    	// Player
    	glBindVertexArray(m_PlayerVAO);
    	glBindTexture(GL_TEXTURE_2D, m_Textures[0]);
    	glUniform1i(glGetUniformLocation(m_Program, "Texture2"), 0);
 
    	m_ProjectionMatrix = glm::translate(glm::mat4(), glm::vec3(PlayerX, PlayerY, 0.0f)) * m_Camera.ViewToWorldMatrix();
    	m_TransformationMatrix = m_ProjectionMatrix;
    	m_TransformationMatrixLoc = glGetUniformLocation(m_Program, "TransformationMatrix");
    	glUniformMatrix4fv(m_TransformationMatrixLoc, 1, GL_FALSE, &m_TransformationMatrix[0][0]);
 
    	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
 
    	glBindTexture(GL_TEXTURE_2D, 0);
    	glBindVertexArray(0);
    }
As you can see, it is unnecessarily complicated. And if I want to draw, say, two or more enemies, or 4 or more platforms, then it'd get ridiculously large! My question is this, how can I make this smaller? I prefer to be able to do something like this in my main.cpp: Sprite.Render(Player); Sprite.Render(EnemyOne); etc...

Looking forward to reading your tips, thank you!