remove all glut

This commit is contained in:
ZappoMan 2014-12-18 16:12:30 -08:00
parent 26bcca95c9
commit 8091564a73
4 changed files with 91 additions and 37 deletions

View file

@ -537,8 +537,6 @@ void Application::initializeGL() {
} else {
isInitialized = true;
}
int argc = 0;
glutInit(&argc, 0);
#endif
#ifdef WIN32

View file

@ -33,12 +33,6 @@
using namespace std;
// no clue which versions are affected...
#define WORKAROUND_BROKEN_GLUT_STROKES
// see http://www.opengl.org/resources/libraries/glut/spec3/node78.html
void renderWorldBox() {
// Show edge of world
float red[] = {1, 0, 0};

View file

@ -1,25 +0,0 @@
//
// GPUConfig.h
// libraries/gpu/src/gpu
//
// Created by Brad Hefta-Gaub on 12/17/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef gpu__GLUTConfig__
#define gpu__GLUTConfig__
// TODO: remove these once we migrate away from GLUT calls
#if defined(__APPLE__)
#include <GLUT/glut.h>
#elif defined(WIN32)
#include <GL/glut.h>
#else
#include <GL/glut.h>
#endif
#endif // gpu__GLUTConfig__

View file

@ -11,7 +11,6 @@
// include this before QOpenGLBuffer, which includes an earlier version of OpenGL
#include <gpu/GPUConfig.h>
#include <gpu/GLUTConfig.h> // TODO - we need to get rid of this ASAP
#include <cmath>
@ -509,7 +508,97 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions) {
}
void GeometryCache::renderSolidCube(float size) {
glutSolidCube(size);
VerticesIndices& vbo = _solidCubeVBOs[size];
const int FLOATS_PER_VERTEX = 3;
const int VERTICES_PER_FACE = 4;
const int NUMBER_OF_FACES = 6;
const int TRIANGLES_PER_FACE = 2;
const int VERTICES_PER_TRIANGLE = 3;
const int vertices = NUMBER_OF_FACES * VERTICES_PER_FACE * FLOATS_PER_VERTEX;
const int indices = NUMBER_OF_FACES * TRIANGLES_PER_FACE * VERTICES_PER_TRIANGLE;
const int vertexPoints = vertices * FLOATS_PER_VERTEX;
if (vbo.first == 0) {
GLfloat* vertexData = new GLfloat[vertexPoints * 2]; // vertices and normals
GLfloat* vertex = vertexData;
float halfSize = size / 2.0f;
static GLfloat cannonicalVertices[vertexPoints] =
{ 1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1, // v0,v1,v2,v3 (front)
1, 1, 1, 1,-1, 1, 1,-1,-1, 1, 1,-1, // v0,v3,v4,v5 (right)
1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1, // v0,v5,v6,v1 (top)
-1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1, // v1,v6,v7,v2 (left)
-1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1, // v7,v4,v3,v2 (bottom)
1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1 }; // v4,v7,v6,v5 (back)
// normal array
static GLfloat cannonicalNormals[vertexPoints] =
{ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, // v0,v1,v2,v3 (front)
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, // v0,v3,v4,v5 (right)
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // v0,v5,v6,v1 (top)
-1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // v1,v6,v7,v2 (left)
0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, // v7,v4,v3,v2 (bottom)
0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1 }; // v4,v7,v6,v5 (back)
// index array of vertex array for glDrawElements() & glDrawRangeElement()
static GLubyte cannonicalIndices[indices] =
{ 0, 1, 2, 2, 3, 0, // front
4, 5, 6, 6, 7, 4, // right
8, 9,10, 10,11, 8, // top
12,13,14, 14,15,12, // left
16,17,18, 18,19,16, // bottom
20,21,22, 22,23,20 }; // back
GLfloat* cannonicalVertex = &cannonicalVertices[0];
GLfloat* cannonicalNormal = &cannonicalNormals[0];
for (int i = 0; i < vertices; i++) {
//normals
*(vertex++) = *cannonicalNormal++;
*(vertex++) = *cannonicalNormal++;
*(vertex++) = *cannonicalNormal++;
// vertices
*(vertex++) = halfSize * *cannonicalVertex++;
*(vertex++) = halfSize * *cannonicalVertex++;
*(vertex++) = halfSize * *cannonicalVertex++;
}
glGenBuffers(1, &vbo.first);
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
glBufferData(GL_ARRAY_BUFFER, vertices * NUM_BYTES_PER_VERTEX, vertexData, GL_STATIC_DRAW);
delete[] vertexData;
GLushort* indexData = new GLushort[indices];
GLushort* index = indexData;
for (int i = 0; i < indices; i++) {
index[i] = cannonicalIndices[i];
}
glGenBuffers(1, &vbo.second);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
delete[] indexData;
} else {
glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
}
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 6 * sizeof(float), 0);
glVertexPointer(3, GL_FLOAT, (6 * sizeof(float)), (const void *)(3 * sizeof(float)));
glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
void GeometryCache::renderWireCube(float size) {
@ -533,7 +622,6 @@ void GeometryCache::renderWireCube(float size) {
};
// index array of vertex array for glDrawRangeElement() as a GL_LINES for each edge
const GLubyte LINE_BREAK = static_cast<GLubyte>(-1);
static GLubyte cannonicalIndices[indices] = {
0, 1, 1, 2, 2, 3, 3, 0, // (top)
4, 5, 5, 6, 6, 7, 7, 4, // (bottom)
@ -571,7 +659,6 @@ void GeometryCache::renderWireCube(float size) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}