From 7211fd7027da38651fcc4d58bfaa5abe4621ab60 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 15 May 2013 13:27:37 -0700 Subject: [PATCH 1/4] Now that we have a Qt context, we can use their shader classes. However, we extend the program object class with glm-enabled functions. --- interface/src/Application.cpp | 30 +++--- interface/src/Environment.cpp | 65 ++++++------ interface/src/renderer/ProgramObject.cpp | 105 +------------------- interface/src/renderer/ProgramObject.h | 47 +-------- interface/src/renderer/ShaderObject.cpp | 39 -------- interface/src/renderer/ShaderObject.h | 36 ------- interface/src/starfield/renderer/Renderer.h | 8 +- 7 files changed, 57 insertions(+), 273 deletions(-) delete mode 100644 interface/src/renderer/ShaderObject.cpp delete mode 100644 interface/src/renderer/ShaderObject.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b5e6ffd3e7..3eeaf809d4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1496,15 +1496,15 @@ void Application::displayOculus(Camera& whichCamera) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); _oculusProgram = new ProgramObject(); - _oculusProgram->attachFromSourceCode(GL_FRAGMENT_SHADER_ARB, DISTORTION_FRAGMENT_SHADER); + _oculusProgram->addShaderFromSourceCode(QGLShader::Fragment, DISTORTION_FRAGMENT_SHADER); _oculusProgram->link(); - _textureLocation = _oculusProgram->getUniformLocation("texture"); - _lensCenterLocation = _oculusProgram->getUniformLocation("lensCenter"); - _screenCenterLocation = _oculusProgram->getUniformLocation("screenCenter"); - _scaleLocation = _oculusProgram->getUniformLocation("scale"); - _scaleInLocation = _oculusProgram->getUniformLocation("scaleIn"); - _hmdWarpParamLocation = _oculusProgram->getUniformLocation("hmdWarpParam"); + _textureLocation = _oculusProgram->uniformLocation("texture"); + _lensCenterLocation = _oculusProgram->uniformLocation("lensCenter"); + _screenCenterLocation = _oculusProgram->uniformLocation("screenCenter"); + _scaleLocation = _oculusProgram->uniformLocation("scale"); + _scaleInLocation = _oculusProgram->uniformLocation("scaleIn"); + _hmdWarpParamLocation = _oculusProgram->uniformLocation("hmdWarpParam"); } else { glBindTexture(GL_TEXTURE_2D, _oculusTextureID); @@ -1525,12 +1525,12 @@ void Application::displayOculus(Camera& whichCamera) { glDisable(GL_BLEND); glEnable(GL_TEXTURE_2D); _oculusProgram->bind(); - _oculusProgram->setUniform(_textureLocation, 0); - _oculusProgram->setUniform(_lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29 - _oculusProgram->setUniform(_screenCenterLocation, 0.25, 0.5); - _oculusProgram->setUniform(_scaleLocation, 0.25 * scaleFactor, 0.5 * scaleFactor * aspectRatio); - _oculusProgram->setUniform(_scaleInLocation, 4, 2 / aspectRatio); - _oculusProgram->setUniform(_hmdWarpParamLocation, 1.0, 0.22, 0.24, 0); + _oculusProgram->setUniformValue(_textureLocation, 0); + _oculusProgram->setUniformValue(_lensCenterLocation, 0.287994, 0.5); // see SDK docs, p. 29 + _oculusProgram->setUniformValue(_screenCenterLocation, 0.25, 0.5); + _oculusProgram->setUniformValue(_scaleLocation, 0.25 * scaleFactor, 0.5 * scaleFactor * aspectRatio); + _oculusProgram->setUniformValue(_scaleInLocation, 4, 2 / aspectRatio); + _oculusProgram->setUniformValue(_hmdWarpParamLocation, 1.0, 0.22, 0.24, 0); glColor3f(1, 0, 1); glBegin(GL_QUADS); @@ -1544,8 +1544,8 @@ void Application::displayOculus(Camera& whichCamera) { glVertex2f(0, _glWidget->height()); glEnd(); - _oculusProgram->setUniform(_lensCenterLocation, 0.787994, 0.5); - _oculusProgram->setUniform(_screenCenterLocation, 0.75, 0.5); + _oculusProgram->setUniformValue(_lensCenterLocation, 0.787994, 0.5); + _oculusProgram->setUniformValue(_screenCenterLocation, 0.75, 0.5); glBegin(GL_QUADS); glTexCoord2f(0.5, 0); diff --git a/interface/src/Environment.cpp b/interface/src/Environment.cpp index a84a90adad..8c16c17479 100644 --- a/interface/src/Environment.cpp +++ b/interface/src/Environment.cpp @@ -12,7 +12,6 @@ #include "Camera.h" #include "Environment.h" #include "renderer/ProgramObject.h" -#include "renderer/ShaderObject.h" #include "world.h" void Environment::init() { @@ -57,24 +56,24 @@ void Environment::renderAtmosphere(Camera& camera) { program->setUniform(locations[CAMERA_POS_LOCATION], relativeCameraPos); glm::vec3 lightDirection = glm::normalize(getSunLocation()); program->setUniform(locations[LIGHT_POS_LOCATION], lightDirection); - program->setUniform(locations[INV_WAVELENGTH_LOCATION], + program->setUniformValue(locations[INV_WAVELENGTH_LOCATION], 1 / powf(getScatteringWavelengths().r, 4.0f), 1 / powf(getScatteringWavelengths().g, 4.0f), 1 / powf(getScatteringWavelengths().b, 4.0f)); - program->setUniform(locations[CAMERA_HEIGHT2_LOCATION], height * height); - program->setUniform(locations[OUTER_RADIUS_LOCATION], getAtmosphereOuterRadius()); - program->setUniform(locations[OUTER_RADIUS2_LOCATION], getAtmosphereOuterRadius() * getAtmosphereOuterRadius()); - program->setUniform(locations[INNER_RADIUS_LOCATION], getAtmosphereInnerRadius()); - program->setUniform(locations[KR_ESUN_LOCATION], getRayleighScattering() * getSunBrightness()); - program->setUniform(locations[KM_ESUN_LOCATION], getMieScattering() * getSunBrightness()); - program->setUniform(locations[KR_4PI_LOCATION], getRayleighScattering() * 4.0f * PIf); - program->setUniform(locations[KM_4PI_LOCATION], getMieScattering() * 4.0f * PIf); - program->setUniform(locations[SCALE_LOCATION], 1.0f / (getAtmosphereOuterRadius() - getAtmosphereInnerRadius())); - program->setUniform(locations[SCALE_DEPTH_LOCATION], 0.25f); - program->setUniform(locations[SCALE_OVER_SCALE_DEPTH_LOCATION], + program->setUniformValue(locations[CAMERA_HEIGHT2_LOCATION], height * height); + program->setUniformValue(locations[OUTER_RADIUS_LOCATION], getAtmosphereOuterRadius()); + program->setUniformValue(locations[OUTER_RADIUS2_LOCATION], getAtmosphereOuterRadius() * getAtmosphereOuterRadius()); + program->setUniformValue(locations[INNER_RADIUS_LOCATION], getAtmosphereInnerRadius()); + program->setUniformValue(locations[KR_ESUN_LOCATION], getRayleighScattering() * getSunBrightness()); + program->setUniformValue(locations[KM_ESUN_LOCATION], getMieScattering() * getSunBrightness()); + program->setUniformValue(locations[KR_4PI_LOCATION], getRayleighScattering() * 4.0f * PIf); + program->setUniformValue(locations[KM_4PI_LOCATION], getMieScattering() * 4.0f * PIf); + program->setUniformValue(locations[SCALE_LOCATION], 1.0f / (getAtmosphereOuterRadius() - getAtmosphereInnerRadius())); + program->setUniformValue(locations[SCALE_DEPTH_LOCATION], 0.25f); + program->setUniformValue(locations[SCALE_OVER_SCALE_DEPTH_LOCATION], (1.0f / (getAtmosphereOuterRadius() - getAtmosphereInnerRadius())) / 0.25f); - program->setUniform(locations[G_LOCATION], -0.990f); - program->setUniform(locations[G2_LOCATION], -0.990f * -0.990f); + program->setUniformValue(locations[G_LOCATION], -0.990f); + program->setUniformValue(locations[G2_LOCATION], -0.990f * -0.990f); glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); @@ -92,26 +91,26 @@ void Environment::renderAtmosphere(Camera& camera) { ProgramObject* Environment::createSkyProgram(const char* from, int* locations) { ProgramObject* program = new ProgramObject(); QByteArray prefix = QByteArray("resources/shaders/SkyFrom") + from; - program->attachFromSourceFile(GL_VERTEX_SHADER_ARB, prefix + ".vert"); - program->attachFromSourceFile(GL_FRAGMENT_SHADER_ARB, prefix + ".frag"); + program->addShaderFromSourceFile(QGLShader::Vertex, prefix + ".vert"); + program->addShaderFromSourceFile(QGLShader::Fragment, prefix + ".frag"); program->link(); - locations[CAMERA_POS_LOCATION] = program->getUniformLocation("v3CameraPos"); - locations[LIGHT_POS_LOCATION] = program->getUniformLocation("v3LightPos"); - locations[INV_WAVELENGTH_LOCATION] = program->getUniformLocation("v3InvWavelength"); - locations[CAMERA_HEIGHT2_LOCATION] = program->getUniformLocation("fCameraHeight2"); - locations[OUTER_RADIUS_LOCATION] = program->getUniformLocation("fOuterRadius"); - locations[OUTER_RADIUS2_LOCATION] = program->getUniformLocation("fOuterRadius2"); - locations[INNER_RADIUS_LOCATION] = program->getUniformLocation("fInnerRadius"); - locations[KR_ESUN_LOCATION] = program->getUniformLocation("fKrESun"); - locations[KM_ESUN_LOCATION] = program->getUniformLocation("fKmESun"); - locations[KR_4PI_LOCATION] = program->getUniformLocation("fKr4PI"); - locations[KM_4PI_LOCATION] = program->getUniformLocation("fKm4PI"); - locations[SCALE_LOCATION] = program->getUniformLocation("fScale"); - locations[SCALE_DEPTH_LOCATION] = program->getUniformLocation("fScaleDepth"); - locations[SCALE_OVER_SCALE_DEPTH_LOCATION] = program->getUniformLocation("fScaleOverScaleDepth"); - locations[G_LOCATION] = program->getUniformLocation("g"); - locations[G2_LOCATION] = program->getUniformLocation("g2"); + locations[CAMERA_POS_LOCATION] = program->uniformLocation("v3CameraPos"); + locations[LIGHT_POS_LOCATION] = program->uniformLocation("v3LightPos"); + locations[INV_WAVELENGTH_LOCATION] = program->uniformLocation("v3InvWavelength"); + locations[CAMERA_HEIGHT2_LOCATION] = program->uniformLocation("fCameraHeight2"); + locations[OUTER_RADIUS_LOCATION] = program->uniformLocation("fOuterRadius"); + locations[OUTER_RADIUS2_LOCATION] = program->uniformLocation("fOuterRadius2"); + locations[INNER_RADIUS_LOCATION] = program->uniformLocation("fInnerRadius"); + locations[KR_ESUN_LOCATION] = program->uniformLocation("fKrESun"); + locations[KM_ESUN_LOCATION] = program->uniformLocation("fKmESun"); + locations[KR_4PI_LOCATION] = program->uniformLocation("fKr4PI"); + locations[KM_4PI_LOCATION] = program->uniformLocation("fKm4PI"); + locations[SCALE_LOCATION] = program->uniformLocation("fScale"); + locations[SCALE_DEPTH_LOCATION] = program->uniformLocation("fScaleDepth"); + locations[SCALE_OVER_SCALE_DEPTH_LOCATION] = program->uniformLocation("fScaleOverScaleDepth"); + locations[G_LOCATION] = program->uniformLocation("g"); + locations[G2_LOCATION] = program->uniformLocation("g2"); return program; } diff --git a/interface/src/renderer/ProgramObject.cpp b/interface/src/renderer/ProgramObject.cpp index d2346bf3b3..5108c15068 100644 --- a/interface/src/renderer/ProgramObject.cpp +++ b/interface/src/renderer/ProgramObject.cpp @@ -6,114 +6,15 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. #include "ProgramObject.h" -#include "ShaderObject.h" -ProgramObject::ProgramObject() : _handle(glCreateProgramObjectARB()) { -} - -ProgramObject::~ProgramObject() { - glDeleteObjectARB(_handle); -} - -void ProgramObject::attach(ShaderObject* shader) { - glAttachObjectARB(_handle, shader->getHandle()); -} - -bool ProgramObject::attachFromSourceCode(int type, const char* source) { - ShaderObject* shader = new ShaderObject(type); - if (shader->compileSourceCode(source)) { - attach(shader); - return true; - - } else { - delete shader; - return false; - } -} - -bool ProgramObject::attachFromSourceFile(int type, const char* filename) { - ShaderObject* shader = new ShaderObject(type); - if (shader->compileSourceFile(filename)) { - attach(shader); - return true; - - } else { - delete shader; - return false; - } -} - -bool ProgramObject::link() { - glLinkProgramARB(_handle); - int status; - glGetObjectParameterivARB(_handle, GL_OBJECT_LINK_STATUS_ARB, &status); - return status; -} - -QByteArray ProgramObject::getLog() const { - int length; - glGetObjectParameterivARB(_handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - QByteArray log(length, 0); - glGetInfoLogARB(_handle, length, 0, log.data()); - return log; -} - -void ProgramObject::bind() const { - glUseProgramObjectARB(_handle); -} - -void ProgramObject::release() const { - glUseProgramObjectARB(0); -} - -int ProgramObject::getUniformLocation(const char* name) const { - return glGetUniformLocationARB(_handle, name); -} - -void ProgramObject::setUniform(int location, int value) { - glUniform1iARB(location, value); -} - -void ProgramObject::setUniform(const char* name, int value) { - setUniform(getUniformLocation(name), value); -} - -void ProgramObject::setUniform(int location, float value) { - glUniform1fARB(location, value); -} - -void ProgramObject::setUniform(const char* name, float value) { - setUniform(getUniformLocation(name), value); -} - -void ProgramObject::setUniform(int location, float x, float y) { - glUniform2fARB(location, x, y); -} - -void ProgramObject::setUniform(const char* name, float x, float y) { - setUniform(getUniformLocation(name), x, y); +ProgramObject::ProgramObject(QObject* parent) : QGLShaderProgram(parent) { } void ProgramObject::setUniform(int location, const glm::vec3& value) { - glUniform3fARB(location, value.x, value.y, value.z); + setUniformValue(location, value.x, value.y, value.z); } void ProgramObject::setUniform(const char* name, const glm::vec3& value) { - setUniform(getUniformLocation(name), value); + setUniformValue(name, value.x, value.y, value.z); } -void ProgramObject::setUniform(int location, float x, float y, float z) { - glUniform3fARB(location, x, y, z); -} - -void ProgramObject::setUniform(const char* name, float x, float y, float z) { - setUniform(getUniformLocation(name), x, y, z); -} - -void ProgramObject::setUniform(int location, float x, float y, float z, float w) { - glUniform4fARB(location, x, y, z, w); -} - -void ProgramObject::setUniform(const char* name, float x, float y, float z, float w) { - setUniform(getUniformLocation(name), x, y, z, w); -} diff --git a/interface/src/renderer/ProgramObject.h b/interface/src/renderer/ProgramObject.h index e46d40c13f..78f07b7a1b 100644 --- a/interface/src/renderer/ProgramObject.h +++ b/interface/src/renderer/ProgramObject.h @@ -9,58 +9,17 @@ #ifndef __interface__ProgramObject__ #define __interface__ProgramObject__ -#include +#include #include -#include "InterfaceConfig.h" - -class ShaderObject; - -class ProgramObject { +class ProgramObject : public QGLShaderProgram { public: - ProgramObject(); - ~ProgramObject(); - - GLhandleARB getHandle() const { return _handle; } + ProgramObject(QObject* parent = 0); - void attach(ShaderObject* shader); - bool attachFromSourceCode(int type, const char* source); - bool attachFromSourceFile(int type, const char* filename); - - bool link(); - - QByteArray getLog() const; - - void bind() const; - void release() const; - - int getUniformLocation(const char* name) const; - - void setUniform(int location, int value); - void setUniform(const char* name, int value); - - void setUniform(int location, float value); - void setUniform(const char* name, float value); - - void setUniform(int location, float x, float y); - void setUniform(const char* name, float x, float y); - void setUniform(int location, const glm::vec3& value); void setUniform(const char* name, const glm::vec3& value); - - void setUniform(int location, float x, float y, float z); - void setUniform(const char* name, float x, float y, float z); - - void setUniform(int location, float x, float y, float z, float w); - void setUniform(const char* name, float x, float y, float z, float w); - -private: - - Q_DISABLE_COPY(ProgramObject) - - GLhandleARB _handle; }; #endif /* defined(__interface__ProgramObject__) */ diff --git a/interface/src/renderer/ShaderObject.cpp b/interface/src/renderer/ShaderObject.cpp deleted file mode 100644 index d6c1e7ced4..0000000000 --- a/interface/src/renderer/ShaderObject.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -// ShaderObject.cpp -// interface -// -// Created by Andrzej Kapolka on 5/7/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. - -#include - -#include "ShaderObject.h" - -ShaderObject::ShaderObject(int type) - : _handle(glCreateShaderObjectARB(type)) { -} - -ShaderObject::~ShaderObject() { - glDeleteObjectARB(_handle); -} - -bool ShaderObject::compileSourceCode(const char* data) { - glShaderSourceARB(_handle, 1, &data, 0); - glCompileShaderARB(_handle); - int status; - glGetObjectParameterivARB(_handle, GL_OBJECT_COMPILE_STATUS_ARB, &status); - return status; -} - -bool ShaderObject::compileSourceFile(const char* filename) { - QFile file(filename); - return file.open(QIODevice::ReadOnly) && compileSourceCode(file.readAll().constData()); -} - -QByteArray ShaderObject::getLog() const { - int length; - glGetObjectParameterivARB(_handle, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); - QByteArray log(length, 0); - glGetInfoLogARB(_handle, length, 0, log.data()); - return log; -} diff --git a/interface/src/renderer/ShaderObject.h b/interface/src/renderer/ShaderObject.h deleted file mode 100644 index 297650a40f..0000000000 --- a/interface/src/renderer/ShaderObject.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// ShaderObject.h -// interface -// -// Created by Andrzej Kapolka on 5/7/13. -// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. -// - -#ifndef __interface__ShaderObject__ -#define __interface__ShaderObject__ - -#include - -#include "InterfaceConfig.h" - -class ShaderObject { -public: - - ShaderObject(int type); - ~ShaderObject(); - - GLhandleARB getHandle() const { return _handle; } - - bool compileSourceCode(const char* data); - bool compileSourceFile(const char* filename); - - QByteArray getLog() const; - -private: - - Q_DISABLE_COPY(ShaderObject) - - GLhandleARB _handle; -}; - -#endif /* defined(__interface__ShaderObject__) */ diff --git a/interface/src/starfield/renderer/Renderer.h b/interface/src/starfield/renderer/Renderer.h index 8a7e4bd6de..97b565c767 100644 --- a/interface/src/starfield/renderer/Renderer.h +++ b/interface/src/starfield/renderer/Renderer.h @@ -478,15 +478,15 @@ namespace starfield { " gl_PointSize = s;\n" "}\n"; - _objProgram.attachFromSourceCode(GL_VERTEX_SHADER, VERTEX_SHADER); + _objProgram.addShaderFromSourceCode(QGLShader::Vertex, VERTEX_SHADER); GLchar const* const FRAGMENT_SHADER = "#version 120\n" "void main(void) {\n" " gl_FragColor = gl_Color;\n" "}\n"; - _objProgram.attachFromSourceCode(GL_FRAGMENT_SHADER, FRAGMENT_SHADER); + _objProgram.addShaderFromSourceCode(QGLShader::Fragment, FRAGMENT_SHADER); _objProgram.link(); - _alphaLocation = _objProgram.getUniformLocation("alpha"); + _alphaLocation = _objProgram.uniformLocation("alpha"); glGenBuffersARB(1, & _hndVertexArray); } @@ -534,7 +534,7 @@ namespace starfield { // select shader and vertex array _objProgram.bind(); - _objProgram.setUniform(_alphaLocation, alpha); + _objProgram.setUniformValue(_alphaLocation, alpha); glBindBufferARB(GL_ARRAY_BUFFER, _hndVertexArray); glInterleavedArrays(GL_C4UB_V3F, sizeof(GpuVertex), 0l); From f15c670c4e0460fe43f329f99b1bf8a6288303f0 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 15 May 2013 16:07:09 -0700 Subject: [PATCH 2/4] Let's try initializing glut before Qt, since we're getting a warning on OS X. --- interface/src/Application.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3eeaf809d4..013f226ad3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -224,15 +224,15 @@ Application::Application(int& argc, char** argv) : // enable mouse tracking; otherwise, we only get drag events _glWidget->setMouseTracking(true); + // initialize glut, which we use for rendering spheres and such + glutInit(&argc, argv); + // initialization continues in initializeGL when OpenGL context is ready } void Application::initializeGL() { printLog( "Created Display Window.\n" ); - int argc = 0; - glutInit(&argc, 0); - #ifdef _WIN32 glewInit(); printLog( "Glew Init complete.\n" ); From f0055bd4199d78b408837658a4cd2f96c6dcf7f3 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 15 May 2013 16:19:42 -0700 Subject: [PATCH 3/4] Fixes for OS X: GLSL version must be first line in source, don't init glut (Qt apparently uses it?) --- interface/resources/shaders/SkyFromAtmosphere.frag | 4 ++-- interface/resources/shaders/SkyFromAtmosphere.vert | 4 ++-- interface/resources/shaders/SkyFromSpace.frag | 4 ++-- interface/resources/shaders/SkyFromSpace.vert | 4 ++-- interface/src/Application.cpp | 9 ++++++--- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/interface/resources/shaders/SkyFromAtmosphere.frag b/interface/resources/shaders/SkyFromAtmosphere.frag index 9f6cc39f1b..37d26ba40a 100644 --- a/interface/resources/shaders/SkyFromAtmosphere.frag +++ b/interface/resources/shaders/SkyFromAtmosphere.frag @@ -1,3 +1,5 @@ +#version 120 + // // For licensing information, see http://http.developer.nvidia.com/GPUGems/gpugems_app01.html: // @@ -30,8 +32,6 @@ // Copyright (c) 2004 Sean O'Neil // -#version 120 - uniform vec3 v3LightPos; uniform float g; uniform float g2; diff --git a/interface/resources/shaders/SkyFromAtmosphere.vert b/interface/resources/shaders/SkyFromAtmosphere.vert index 2587d262a2..90fcbc5281 100644 --- a/interface/resources/shaders/SkyFromAtmosphere.vert +++ b/interface/resources/shaders/SkyFromAtmosphere.vert @@ -1,3 +1,5 @@ +#version 120 + // // For licensing information, see http://http.developer.nvidia.com/GPUGems/gpugems_app01.html: // @@ -30,8 +32,6 @@ // Copyright (c) 2004 Sean O'Neil // -#version 120 - uniform vec3 v3CameraPos; // The camera's current position uniform vec3 v3LightPos; // The direction vector to the light source uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels diff --git a/interface/resources/shaders/SkyFromSpace.frag b/interface/resources/shaders/SkyFromSpace.frag index be872c5dbd..b40dc98bd8 100644 --- a/interface/resources/shaders/SkyFromSpace.frag +++ b/interface/resources/shaders/SkyFromSpace.frag @@ -1,3 +1,5 @@ +#version 120 + // // For licensing information, see http://http.developer.nvidia.com/GPUGems/gpugems_app01.html: // @@ -30,8 +32,6 @@ // Copyright (c) 2004 Sean O'Neil // -#version 120 - uniform vec3 v3LightPos; uniform float g; uniform float g2; diff --git a/interface/resources/shaders/SkyFromSpace.vert b/interface/resources/shaders/SkyFromSpace.vert index d230ee8518..2a9907565f 100644 --- a/interface/resources/shaders/SkyFromSpace.vert +++ b/interface/resources/shaders/SkyFromSpace.vert @@ -1,3 +1,5 @@ +#version 120 + // // For licensing information, see http://http.developer.nvidia.com/GPUGems/gpugems_app01.html: // @@ -30,8 +32,6 @@ // Copyright (c) 2004 Sean O'Neil // -#version 120 - uniform vec3 v3CameraPos; // The camera's current position uniform vec3 v3LightPos; // The direction vector to the light source uniform vec3 v3InvWavelength; // 1 / pow(wavelength, 4) for the red, green, and blue channels diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 013f226ad3..608d56ada9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -224,15 +224,18 @@ Application::Application(int& argc, char** argv) : // enable mouse tracking; otherwise, we only get drag events _glWidget->setMouseTracking(true); - // initialize glut, which we use for rendering spheres and such - glutInit(&argc, argv); - // initialization continues in initializeGL when OpenGL context is ready } void Application::initializeGL() { printLog( "Created Display Window.\n" ); + // initialize glut for shape drawing; Qt apparently initializes it on OS X + #ifndef __APPLE__ + int argc = 0; + glutInit(&argc, 0); + #endif + #ifdef _WIN32 glewInit(); printLog( "Glew Init complete.\n" ); From a571caac8fcfb6bcb332079735c029ec42649347 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Wed, 15 May 2013 16:24:22 -0700 Subject: [PATCH 4/4] Build fix. --- eve/src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/eve/src/main.cpp b/eve/src/main.cpp index 4361db107d..666181a00f 100644 --- a/eve/src/main.cpp +++ b/eve/src/main.cpp @@ -6,6 +6,7 @@ // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. // +#include #include #include