OpenGL
The OpenGL plugin integrates Tellusim SDK with the OpenGL API, enabling interoperability between Tellusim-managed GPU resources and native OpenGL applications.
#include <platform/opengl/include/TellusimGL.h>
Example
This example demonstrates how to integrate native OpenGL rendering into Tellusim application:
// create command list
Command command = device.createCommand(target);
// set pipeline
command.setPipeline(pipeline);
// set model buffers
model.setBuffers(command);
// set common parameters
CommonParameters common_parameters;
common_parameters.camera = Vector4f(3.0f, 3.0f, 2.0f, 0.0f);
common_parameters.projection = Matrix4x4f::perspective(60.0f, (float32_t)window.getWidth() / window.getHeight(), 0.1f, 1000.0f);
common_parameters.modelview = Matrix4x4f::lookAt(Vector3f(common_parameters.camera), Vector3f(0.0f, 0.0f, 0.0f), Vector3f(0.0f, 0.0f, 1.0f));
common_parameters.transform = Matrix4x4f::rotateX(time * 16.0f) * Matrix4x4f::rotateY(time * 24.0f) * Matrix4x4f::rotateZ(time * 32.0f);
command.setUniform(0, common_parameters);
// draw model with OpenGL API
for(uint32_t i = 0; i < model.getNumGeometries(); i++) {
uint32_t num_indices = model.getNumGeometryIndices(i);
uint32_t base_index = model.getGeometryBaseIndex(i);
uint32_t base_vertex = model.getGeometryBaseVertex(i);
glDrawElementsBaseVertex(GL_TRIANGLES, num_indices, GL_UNSIGNED_SHORT, (const void*)(size_t)(base_index << 2), base_vertex);
}