#include "SimpleOpenGL2Renderer.h" #include "OpenGL2Include.h" #include "Bullet3Common/b3Vector3.h" SimpleOpenGL2Renderer::SimpleOpenGL2Renderer(int width, int height) :m_width(width), m_height(height) { } void SimpleOpenGL2Renderer::init() { } void SimpleOpenGL2Renderer::updateCamera(int upAxis) { float projection[16]; float view[16]; m_camera.setAspectRatio((float)m_width/(float)m_height); m_camera.update(); m_camera.getCameraProjectionMatrix(projection); m_camera.getCameraViewMatrix(view); GLfloat projMat[16]; GLfloat viewMat[16]; for (int i=0;i<16;i++) { viewMat[i] = view[i]; projMat[i] = projection[i]; } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMultMatrixf(projMat); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixf(viewMat); } void SimpleOpenGL2Renderer::removeAllInstances() { } void SimpleOpenGL2Renderer::setCameraDistance(float dist) { m_camera.setCameraDistance(dist); } void SimpleOpenGL2Renderer::setCameraPitch(float pitch) { m_camera.setCameraPitch(pitch); } void SimpleOpenGL2Renderer::setCameraTargetPosition(float x, float y, float z) { m_camera.setCameraTargetPosition(x,y,z); } void SimpleOpenGL2Renderer::getCameraPosition(float cameraPos[4]) { float pos[3]; m_camera.getCameraPosition(pos); cameraPos[0] = pos[0]; cameraPos[1] = pos[1]; cameraPos[2] = pos[2]; } void SimpleOpenGL2Renderer::getCameraPosition(double cameraPos[4]) { float pos[3]; m_camera.getCameraPosition(pos); cameraPos[0] = pos[0]; cameraPos[1] = pos[1]; cameraPos[2] = pos[2]; } void SimpleOpenGL2Renderer::setCameraTargetPosition(float cameraPos[4]) { m_camera.setCameraTargetPosition(cameraPos[0],cameraPos[1],cameraPos[2]); } void SimpleOpenGL2Renderer::getCameraTargetPosition(float cameraPos[4]) const { m_camera.getCameraTargetPosition(cameraPos); } void SimpleOpenGL2Renderer::getCameraTargetPosition(double cameraPos[4]) const { cameraPos[0] = 1; cameraPos[1] = 1; cameraPos[2] = 1; } void SimpleOpenGL2Renderer::writeSingleInstanceColorToCPU(float* color, int srcIndex) { } void SimpleOpenGL2Renderer::writeSingleInstanceColorToCPU(double* color, int srcIndex) { } void SimpleOpenGL2Renderer::getCameraViewMatrix(float viewMat[16]) const { b3Assert(0); } void SimpleOpenGL2Renderer::getCameraProjectionMatrix(float projMat[16]) const { b3Assert(0); } void SimpleOpenGL2Renderer::renderScene() { } int SimpleOpenGL2Renderer::registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* scaling) { return 0; } int SimpleOpenGL2Renderer::registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling) { return 0; } void SimpleOpenGL2Renderer::drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float pointDrawSize) { int pointStrideInFloats = pointStrideInBytes/4; glLineWidth(pointDrawSize); for (int i=0;i