...
 
Commits (21)
......@@ -10,6 +10,12 @@
* --no-splash : Disable splash screen\n
* --disable-stereo : Disable Stereo Mode\n
*
* OpenGL Options:\n
* -profile < compat | core > : request Compatibility or %Core context ( Default = %Core )\n
* -glVersion <int.int> : request specified OpenGL version (Default = 3.2)\n
* -samples <int> : request MSAA with <int> samples (Default = 16)\n
* \note The OpenGL command line parameters override stored settings temporarily. To permanently store an OpenGL setting, use the options dialog.
*
* Log options:\n
* --log-to-console ( -c ) : Write logger window contents to console\n
* \note On Window Systems, using the --log-to-console option causes the creation of a console if OpenFlipper was started without one.
......
......@@ -350,9 +350,14 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, QString *err
QCommandLineOption coreProfileOption("core-profile",QCoreApplication::translate("main", "OpenGL Core Profile Mode"));
parser.addOption(coreProfileOption);
QCommandLineOption profileOption("profile",QCoreApplication::translate("main","Request OpenGL context profile <profile> with profile set as compat or core"),QCoreApplication::translate("main","<compat | core >"));
profileOption.setDefaultValue("compat");
QCommandLineOption glVersionOption("glVersion",QCoreApplication::translate("main","Request OpenGL version <major>.<minor> "),QCoreApplication::translate("main","< 1.0 | 1.1 | ... | 4.6 >"));
parser.addOption(glVersionOption);
QCommandLineOption samplesOption("samples",QCoreApplication::translate("main","Overwrite multisampling sample count"),QCoreApplication::translate("main","< 0 | 1 | 2 | ... | 16 >"));
parser.addOption(samplesOption);
QCommandLineOption profileOption("profile",QCoreApplication::translate("main","Request OpenGL context profile <profile> with profile set as compat or core"),QCoreApplication::translate("main","< compat | core >"));
parser.addOption(profileOption);
const QCommandLineOption helpOption = parser.addHelpOption();
const QCommandLineOption versionOption = parser.addVersionOption();
......@@ -415,20 +420,30 @@ CommandLineParseResult parseCommandLine(QCommandLineParser &parser, QString *err
std::cerr << "Got port option : " << port.toStdString() << std::endl;
OpenFlipper::Options::remoteControl(port.toInt());
}
if(parser.isSet("samples"))
OpenFlipper::Options::samples(parser.value("samples").toInt(),true);
if(parser.isSet("glVersion"))
{
QStringList values = parser.value("glVersion").split(".");
QPair<int,int> version(
values[0].toInt(),
values[1].toInt());
OpenFlipper::Options::glVersion(version,true);
}
if(parser.value(profileOption)=="core")
{
OpenFlipper::Options::coreProfile(true);
OpenFlipper::Options::coreProfile(true, true);
}
else
{
if(parser.value(profileOption)=="compat")
{
OpenFlipper::Options::coreProfile(false);
OpenFlipper::Options::coreProfile(false, true);
}
}
if(parser.isSet(coreProfileOption)) {
OpenFlipper::Options::coreProfile(true);
OpenFlipper::Options::coreProfile(true, true);
}
return CommandLineOk;
......@@ -514,7 +529,8 @@ int main(int argc, char **argv)
#if QT_VERSION >= 0x050500
QSurfaceFormat format;
format.setVersion(4, 4);
QPair<int,int> version = OpenFlipper::Options::glVersion();
format.setVersion(version.first, version.second);
if (OpenFlipper::Options::coreProfile())
{
......@@ -528,6 +544,7 @@ int main(int argc, char **argv)
if (OpenFlipper::Options::debug())
format.setOption(format.options() | QSurfaceFormat::DebugContext);
format.setSamples(OpenFlipper::Options::samples());
QSurfaceFormat::setDefaultFormat(format);
......
......@@ -138,6 +138,15 @@ static bool stereo_ = true;
/// Use opengl core profile mode?
static bool coreProfile_ = false;
static bool profileOverride_ = false;
/// Requested Opengl version
static QPair<int,int> version_ {4,6};
static bool versionOverride_ = false;
/// Requested OpenGL multisampling
static int samples_ = 4;
static bool samplesOverride_ = false;
/// Store the opengl stereo support
static bool glStereo_ = true;
......@@ -378,23 +387,69 @@ bool stereo( ) {
}
/// Store opengl core profile setting
void coreProfile( bool _enableCoreProfile ) {
coreProfile_ = _enableCoreProfile;
void coreProfile( bool _enableCoreProfile, bool _temporary ) {
if(_temporary)
{
profileOverride_ = true;
coreProfile_ = _enableCoreProfile;
}
else
OpenFlipperSettings().setValue("Core/OpenGL/CoreProfile",_enableCoreProfile);
}
/// get opengl core profile setting
bool coreProfile( ) {
return coreProfile_;
if(profileOverride_)
return coreProfile_;
else
return OpenFlipperSettings().value("Core/OpenGL/CoreProfile",true).toBool();
}
/// get opengl version setting
QPair<int,int> glVersion(){
if(versionOverride_)
return version_;
else
{
// unfortunately QVariant cant store QPair directly, we could try std::pair but its good for now
int major = OpenFlipperSettings().value("Core/OpenGL/VersionMajor", 4).value<int>();
int minor = OpenFlipperSettings().value("Core/OpenGL/VersionMinor", 6).value<int>();
return QPair<int, int>(major,minor);
}
}
/// Store opengl version setting
void glVersion(const QPair<int,int> & _version, bool _temporary)
{
//possible enhancement: check for validity
if(_temporary)
{
version_ = _version;
versionOverride_ = true;
}
else
{
OpenFlipperSettings().setValue("Core/OpenGL/VersionMajor",_version.first);
OpenFlipperSettings().setValue("Core/OpenGL/VersionMinor",_version.second);
}
}
/// Store opengl MSAA sample count
void samples(int _samples) {
OpenFlipperSettings().setValue("Core/OpenGL/Samples",_samples);
void samples(int _samples, bool _temporary) {
if(_temporary)
{
samples_ = _samples;
samplesOverride_ = true;
}
else
OpenFlipperSettings().setValue("Core/OpenGL/Samples",_samples);
}
/// Get opengl MSAA sample count
int samples() {
return OpenFlipperSettings().value("Core/OpenGL/Samples",4).toInt();
if(samplesOverride_)
return samples_;
else
return OpenFlipperSettings().value("Core/OpenGL/Samples",4).toInt();
}
/// Store opengl stereo mode setting
......
......@@ -417,15 +417,23 @@ QString helpDirStr();
/// Store opengl core profile setting
DLLEXPORT
void coreProfile(bool _enableCoreProfile);
void coreProfile(bool _enableCoreProfile, bool _temporary = false);
/// get opengl core profile setting
DLLEXPORT
bool coreProfile( );
/// get opengl version setting
DLLEXPORT
QPair<int,int> glVersion();
/// set opengl version setting
DLLEXPORT
void glVersion(const QPair<int, int>& _version, bool _teporary = false);
/// Store opengl MSAA sample count
DLLEXPORT
void samples(int _samples);
void samples(int _samples, bool _temporary = false);
/// Get opengl MSAA sample count
DLLEXPORT
......
......@@ -68,17 +68,17 @@ DrawMeshBase::DrawMeshBase() :
}
DrawMeshBase::~DrawMeshBase() {
if (vbo_) glDeleteBuffersARB(1, &vbo_);
if (ibo_) glDeleteBuffersARB(1, &ibo_);
if (lineIBO_) glDeleteBuffersARB(1, &lineIBO_);
if (heVBO_) glDeleteBuffersARB(1, &heVBO_);
if (vbo_) glDeleteBuffers(1, &vbo_);
if (ibo_) glDeleteBuffers(1, &ibo_);
if (lineIBO_) glDeleteBuffers(1, &lineIBO_);
if (heVBO_) glDeleteBuffers(1, &heVBO_);
delete vertexDecl_;
delete vertexDeclEdgeCol_;
delete vertexDeclHalfedgeCol_;
delete vertexDeclHalfedgePos_;
if (pickVertexIBO_) glDeleteBuffersARB(1, &pickVertexIBO_);
if (pickVertexIBO_) glDeleteBuffers(1, &pickVertexIBO_);
}
void DrawMeshBase::deleteIbo() {
......@@ -89,21 +89,21 @@ void DrawMeshBase::deleteIbo() {
void DrawMeshBase::bindVbo() {
if (!vbo_)
glGenBuffersARB(1, &vbo_);
glGenBuffers(1, &vbo_);
ACG::GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
}
void DrawMeshBase::bindIbo() {
if (!ibo_)
glGenBuffersARB(1, &ibo_);
glGenBuffers(1, &ibo_);
ACG::GLState::bindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo_);
}
void DrawMeshBase::bindLineIbo() {
if (!lineIBO_)
glGenBuffersARB(1, &lineIBO_);
glGenBuffers(1, &lineIBO_);
ACG::GLState::bindBufferARB(GL_ELEMENT_ARRAY_BUFFER, lineIBO_);
}
......@@ -111,7 +111,7 @@ void DrawMeshBase::bindLineIbo() {
void DrawMeshBase::bindHEVbo() {
glGetIntegerv(GL_ARRAY_BUFFER_BINDING,&prevVBO_);
if (!heVBO_)
glGenBuffersARB(1, &heVBO_);
glGenBuffers(1, &heVBO_);
ACG::GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, heVBO_);
}
......@@ -122,13 +122,13 @@ void DrawMeshBase::unbindHEVbo() {
void DrawMeshBase::bindPickVertexIbo() {
if (!pickVertexIBO_)
glGenBuffersARB(1, &pickVertexIBO_);
glGenBuffers(1, &pickVertexIBO_);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, pickVertexIBO_);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, pickVertexIBO_);
}
void DrawMeshBase::createIndexBuffer() {
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
numTris_ * 3 * sizeof(unsigned int),
meshComp_->getIndexBuffer(), GL_STATIC_DRAW_ARB);
}
......@@ -136,11 +136,11 @@ void DrawMeshBase::createIndexBuffer() {
void DrawMeshBase::fillLineBuffer(size_t n_edges, void *data) {
// 2 or 4 byte indices:
if (indexType_ == GL_UNSIGNED_SHORT)
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
n_edges * 2 * sizeof(unsigned short),
data, GL_STATIC_DRAW_ARB);
else
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
n_edges * 2 * sizeof(unsigned int),
data, GL_STATIC_DRAW_ARB);
}
......@@ -154,11 +154,11 @@ void DrawMeshBase::fillHEVBO(size_t numberOfElements_, size_t sizeOfElements_, v
void DrawMeshBase::fillVertexBuffer() {
if (!vertices_.empty())
glBufferDataARB(GL_ARRAY_BUFFER_ARB, numVerts_ * vertexDecl_->getVertexStride(), &vertices_[0], GL_STATIC_DRAW_ARB);
glBufferData(GL_ARRAY_BUFFER_ARB, numVerts_ * vertexDecl_->getVertexStride(), &vertices_[0], GL_STATIC_DRAW_ARB);
}
void DrawMeshBase::fillInvVertexMap(size_t n_vertices, void *data) {
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(int) * n_vertices, data, GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(int) * n_vertices, data, GL_STATIC_DRAW);
}
} /* namespace ACG */
......@@ -1120,7 +1120,7 @@ DrawMeshT<Mesh>::createIBO()
// for (unsigned int i = 0; i < numTris_ * 3; ++i)
// pwIndices[i] = (unsigned short)indices_[i];
//
// glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, numTris_ * 3 * sizeof(unsigned short), pwIndices, GL_STATIC_DRAW_ARB);
// glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB, numTris_ * 3 * sizeof(unsigned short), pwIndices, GL_STATIC_DRAW_ARB);
// }
// else
createIndexBuffer();
......@@ -1447,7 +1447,7 @@ void ACG::DrawMeshT<Mesh>::addTriRenderObjects(IRenderer* _renderer, const Rende
}
else // no texture map specified, use whatever texture is currently bound to the first texture stage
{
glActiveTextureARB(GL_TEXTURE0);
GLState::activeTexture(GL_TEXTURE0);
GLint textureID = 0;
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureID);
......
......@@ -100,7 +100,7 @@ init()
// test whether fbo hasn't been created before
if(!fbo_)
glGenFramebuffersEXT( 1, &fbo_ );
glGenFramebuffers( 1, &fbo_ );
// check status
checkFramebufferStatus();
......@@ -112,15 +112,15 @@ void FBO::del()
{
// delete framebuffer object
if(fbo_)
glDeleteFramebuffersEXT( 1, &fbo_ );
glDeleteFramebuffers( 1, &fbo_ );
// delete render buffer
if(depthbuffer_)
glDeleteRenderbuffersEXT(1, &depthbuffer_);
glDeleteRenderbuffers(1, &depthbuffer_);
// delete stencil buffer
if(stencilbuffer_)
glDeleteRenderbuffersEXT(1, &stencilbuffer_);
glDeleteRenderbuffers(1, &stencilbuffer_);
for (AttachmentList::iterator it = attachments_.begin(); it != attachments_.end(); ++it)
if (it->second.id && it->second.owner)
......@@ -177,7 +177,7 @@ attachTexture2D( GLenum _attachment, GLuint _texture, GLenum _target )
bind();
// add texture to frame buffer object
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, _attachment, _target, _texture, 0 );
glFramebufferTexture2D( GL_FRAMEBUFFER_EXT, _attachment, _target, _texture, 0 );
checkGLError();
......@@ -350,24 +350,24 @@ FBO::
addDepthBuffer( GLuint _width, GLuint _height )
{
if (depthbuffer_)
glDeleteRenderbuffersEXT(1, &depthbuffer_);
glDeleteRenderbuffers(1, &depthbuffer_);
// create renderbuffer
glGenRenderbuffersEXT(1, &depthbuffer_);
glGenRenderbuffers(1, &depthbuffer_);
// bind renderbuffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer_);
// malloc
#ifdef GL_ARB_texture_multisample
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples_, GL_DEPTH_COMPONENT, _width, _height);
glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, samples_, GL_DEPTH_COMPONENT, _width, _height);
#else
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, _width, _height);
glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, _width, _height);
#endif
// attach to framebuffer object
if ( bind() )
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
// check status
checkFramebufferStatus();
......@@ -383,24 +383,24 @@ FBO::
addStencilBuffer( GLuint _width, GLuint _height )
{
if (stencilbuffer_)
glDeleteRenderbuffersEXT(1, &stencilbuffer_);
glDeleteRenderbuffers(1, &stencilbuffer_);
// create renderbuffer
glGenRenderbuffersEXT(1, &stencilbuffer_);
glGenRenderbuffers(1, &stencilbuffer_);
// bind renderbuffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, stencilbuffer_);
// malloc
#ifdef GL_ARB_texture_multisample
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples_, GL_STENCIL_INDEX, _width, _height);
glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, samples_, GL_STENCIL_INDEX, _width, _height);
#else
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX, _width, _height);
glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX, _width, _height);
#endif
// attach to framebuffer object
if ( bind() )
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, stencilbuffer_);
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, stencilbuffer_);
// check status
checkFramebufferStatus();
......@@ -416,31 +416,31 @@ FBO::
addDepthStencilBuffer( GLuint _width, GLuint _height )
{
if (depthbuffer_)
glDeleteRenderbuffersEXT(1, &depthbuffer_);
glDeleteRenderbuffers(1, &depthbuffer_);
if (stencilbuffer_)
glDeleteRenderbuffersEXT(1, &stencilbuffer_);
glDeleteRenderbuffers(1, &stencilbuffer_);
depthbuffer_ = stencilbuffer_ = 0;
// create renderbuffer
glGenRenderbuffersEXT(1, &depthbuffer_);
glGenRenderbuffers(1, &depthbuffer_);
// bind renderbuffer
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthbuffer_);
// malloc
#ifdef GL_ARB_texture_multisample
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, samples_, GL_DEPTH_STENCIL, _width, _height);
glRenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, samples_, GL_DEPTH_STENCIL, _width, _height);
#else
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL, _width, _height);
glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL, _width, _height);
#endif
// attach to framebuffer object
if (bind())
{
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthbuffer_);
}
// check status
......@@ -492,7 +492,7 @@ FBO::
checkFramebufferStatus()
{
GLenum status;
status = ( GLenum ) glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
status = ( GLenum ) glCheckFramebufferStatus( GL_FRAMEBUFFER_EXT );
//std::cout << "Framebuffer status: " << status << std::endl;
switch ( status )
{
......@@ -556,8 +556,8 @@ void FBO::resize( GLsizei _width, GLsizei _height, bool _forceResize )
// safest way to resize is to first delete the FBO and all its internal textures, and then rebuild
if (fbo_)
glDeleteFramebuffersEXT(1, &fbo_);
glGenFramebuffersEXT(1, &fbo_);
glDeleteFramebuffers(1, &fbo_);
glGenFramebuffers(1, &fbo_);
// "detach" all textures
AttachmentList temp;
......
......@@ -2177,7 +2177,7 @@ void GLState::useProgram(GLuint _program)
}
void GLState::genBuffersARB(GLsizei n, GLuint* buffers) {
glGenBuffersARB(n, buffers);
glGenBuffers(n, buffers);
}
void GLState::genBuffers(GLsizei n, GLuint* buffers) {
......@@ -2186,7 +2186,7 @@ void GLState::genBuffers(GLsizei n, GLuint* buffers) {
void GLState::bufferDataARB(
GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage) {
glBufferDataARB(target, size, data, usage);
glBufferData(target, size, data, usage);
}
void GLState::bufferData(
......
......@@ -533,7 +533,7 @@ public:
//===========================================================================
/**
* Simple wrapper around glGenBuffersARB.
* Simple wrapper around glGenBuffers.
* Useful where glew cannot be included.
*/
static void genBuffersARB(GLsizei n, GLuint* buffers);
......@@ -545,7 +545,7 @@ public:
static void genBuffers(GLsizei n, GLuint* buffers);
/**
* Simple wrapper around glBufferDataARB.
* Simple wrapper around glBufferData.
* Useful where glew cannot be included.
*/
static void bufferDataARB(
......
......@@ -320,13 +320,16 @@ Texture2D::Texture2D(GLenum unit)
bool Texture2D::autogenerateMipMaps()
{
if(openGLVersion(3,0))
{
// From OpenGL 3.0, glGenerateMipmap is supported and we should use that
// but glGenerateMipmap must be called AFTER the data was uploaded.
return false;
}
#ifdef GL_SGIS_generate_mipmap
if (supportsGenerateMipmap())
{
//parameter based mipmap generation was removed in 3.1
if( openGLVersion(3,1))
glGenerateMipmap(GL_TEXTURE_2D);
else
parameter(GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
return true;
}
......@@ -349,13 +352,14 @@ void Texture2D::disableAutogenerateMipMaps()
//-----------------------------------------------------------------------------
void Texture2D::setData(GLint _level,
GLint _internalFormat,
GLsizei _width,
GLsizei _height,
void Texture2D::setData(GLint _level,
GLint _internalFormat,
GLsizei _width,
GLsizei _height,
GLenum _format,
GLenum _type,
const GLvoid* _data) {
const GLvoid* _data,
bool _mipmaps) {
if (getUnit() == GL_NONE)
setUnit(GL_TEXTURE0);
......@@ -367,6 +371,10 @@ void Texture2D::setData(GLint _level,
else
glTexImage2D(GL_TEXTURE_2D, _level, _internalFormat, _width, _height, 0, _format, _type, _data);
// If mip maps should not be built on cpu and the OpenGL version is high enough, we go the default way
if(_mipmaps && !buildMipsCPU_ && openGLVersion(3,0))
glGenerateMipmap(GL_TEXTURE_2D);
width_ = _width;
height_ = _height;
internalFormat_ = _internalFormat;
......@@ -642,7 +650,7 @@ bool Texture2D::loadFromFile( const std::string& _filename, GLenum _minFilter, G
QImage gltex = ACG::Util::convertToGLFormat(qtex);
setData(0, GL_RGBA, gltex.width(), gltex.height(), GL_RGBA, GL_UNSIGNED_BYTE, gltex.bits());
setData(0, GL_RGBA, gltex.width(), gltex.height(), GL_RGBA, GL_UNSIGNED_BYTE, gltex.bits(), mipmaps);
}
}
......@@ -855,11 +863,11 @@ bool TextureBuffer::getBufferData(std::vector<char>& _dst) {
void ProgramBaseNV::bind() {
if (!valid)
gen();
glBindProgramNV(target, program);
glBindProgramARB(target, program);
}
void ProgramBaseNV::unbind() {
glBindProgramNV(target, 0);
glBindProgramARB(target, 0);
}
bool ProgramBaseNV::load(const char* prog_text) {
......@@ -882,13 +890,13 @@ bool ProgramBaseNV::load(const char* prog_text) {
void ProgramBaseNV::gen() {
glGenProgramsNV(1, &program);
glGenProgramsARB(1, &program);
valid = true;
}
void ProgramBaseNV::del() {
if (valid)
glDeleteProgramsNV(1, &program);
glDeleteProgramsARB(1, &program);
valid = false;
}
......
......@@ -412,7 +412,7 @@ public:
void disableAutogenerateMipMaps();
// initialize and set texture data via glTexImage2D
void setData(GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLenum _format, GLenum _type, const GLvoid* _data);
void setData(GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLenum _format, GLenum _type, const GLvoid* _data, bool _mipmaps = false);
// specify storage of texture (OpenGL 4.2)
// use setData with a nullptr instead if 4.2 is not available
......
......@@ -87,7 +87,7 @@ LineNode::LineNode( LineMode _mode,
LineNode::~LineNode() {
if (vbo_)
glDeleteBuffersARB(1, &vbo_);
glDeleteBuffers(1, &vbo_);
}
......@@ -451,7 +451,7 @@ void LineNode::createVBO()
// create vbo if it does not exist
if (!vbo_)
glGenBuffersARB(1, &vbo_);
glGenBuffers(1, &vbo_);
vertexDecl_.clear();
vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_POSITION);
......@@ -568,8 +568,8 @@ void LineNode::createVBO()
}
}
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, vboData.size()*sizeof(float) , &vboData[0] , GL_STATIC_DRAW_ARB);
glBindBuffer(GL_ARRAY_BUFFER_ARB, vbo_);
glBufferData(GL_ARRAY_BUFFER_ARB, vboData.size()*sizeof(float) , &vboData[0] , GL_STATIC_DRAW_ARB);
// Update done.
updateVBO_ = false;
......
......@@ -128,13 +128,13 @@ MeshNodeDeprecatedT<Mesh>::
~MeshNodeDeprecatedT()
{
if (vertex_buffer_)
glDeleteBuffersARB(1, (GLuint*) &vertex_buffer_);
glDeleteBuffers(1, (GLuint*) &vertex_buffer_);
if (normal_buffer_)
glDeleteBuffersARB(1, (GLuint*) &normal_buffer_);
glDeleteBuffers(1, (GLuint*) &normal_buffer_);
if (face_index_buffer_)
glDeleteBuffersARB(1, (GLuint*) &face_index_buffer_ );
glDeleteBuffers(1, (GLuint*) &face_index_buffer_ );
if (faceList_)
glDeleteLists (faceList_, 1);
......@@ -420,7 +420,7 @@ update_geometry()
// Generate a vertex buffer on the GPU
//===================================================================
if (!vertex_buffer_) glGenBuffersARB(1, (GLuint*) &vertex_buffer_);
if (!vertex_buffer_) glGenBuffers(1, (GLuint*) &vertex_buffer_);
ACG::GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, vertex_buffer_);
vertexBufferInitialized_ = false;
......@@ -428,7 +428,7 @@ update_geometry()
//Check if using floats otherwise convert to internal float array
if ( sizeof(PointScalar) == 4 ) {
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
glBufferData(GL_ARRAY_BUFFER_ARB,
3 * mesh_.n_vertices() * sizeof(PointScalar),
mesh_.points(),
GL_STATIC_DRAW_ARB);
......@@ -446,7 +446,7 @@ update_geometry()
if ( !vertices_.empty() ) {
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
glBufferData(GL_ARRAY_BUFFER_ARB,
3 * mesh_.n_vertices() * sizeof(float),
&vertices_[0],
GL_STATIC_DRAW_ARB);
......@@ -459,14 +459,14 @@ update_geometry()
// Generate a normal buffer on the GPU
//===================================================================
if (!normal_buffer_) glGenBuffersARB(1, (GLuint*) &normal_buffer_);
if (!normal_buffer_) glGenBuffers(1, (GLuint*) &normal_buffer_);
ACG::GLState::bindBufferARB(GL_ARRAY_BUFFER_ARB, normal_buffer_);
normalBufferInitialized_ = false;
// Check if using floats otherwise convert to internal float array
if ( sizeof(NormalScalar) == 4) {
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
glBufferData(GL_ARRAY_BUFFER_ARB,
3 * mesh_.n_vertices() * sizeof(NormalScalar),
mesh_.vertex_normals(),
GL_STATIC_DRAW_ARB);
......@@ -483,7 +483,7 @@ update_geometry()
if ( !normals_.empty() ) {
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
glBufferData(GL_ARRAY_BUFFER_ARB,
3 * mesh_.n_vertices() * sizeof(float),
&normals_[0],
GL_STATIC_DRAW_ARB);
......@@ -545,12 +545,12 @@ update_topology()
if ( !indices_.empty() ) {
// generate buffer
if (!face_index_buffer_) glGenBuffersARB(1, (GLuint*) &face_index_buffer_);
if (!face_index_buffer_) glGenBuffers(1, (GLuint*) &face_index_buffer_);
// index buffer
ACG::GLState::bindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, face_index_buffer_);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
glBufferData(GL_ELEMENT_ARRAY_BUFFER_ARB,
indices_.size() * sizeof(unsigned int),
&indices_[0],
GL_STATIC_DRAW_ARB);
......
......@@ -1298,7 +1298,7 @@ void PrincipalAxisNode::createVBO() {
// create vbo if it does not exist
if (!vbo_)
glGenBuffersARB(1, &vbo_);
glGenBuffers(1, &vbo_);
int tensorComponentCount = 0;
for (int i = 0; i < 3; ++i) {
......@@ -1351,8 +1351,8 @@ void PrincipalAxisNode::createVBO() {
}
assert(vboPtr == &vboData[0] + vboData.size());
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, vboData.size() * sizeof(float),
glBindBuffer(GL_ARRAY_BUFFER_ARB, vbo_);
glBufferData(GL_ARRAY_BUFFER_ARB, vboData.size() * sizeof(float),
&vboData[0], GL_STATIC_DRAW_ARB);
// Update done.
......
......@@ -532,16 +532,16 @@ updateVBO() {
if (oldVboSize_ != vertexBuffer_.size())
{
glBufferDataARB( GL_ARRAY_BUFFER_ARB, vertexBuffer_.size() * sizeof(GLfloat), 0, GL_DYNAMIC_DRAW_ARB );
glBufferData( GL_ARRAY_BUFFER_ARB, vertexBuffer_.size() * sizeof(GLfloat), 0, GL_DYNAMIC_DRAW_ARB );
oldVboSize_ = vertexBuffer_.size();
}
// get pointer to VBO memory
GLfloat *data = reinterpret_cast<GLfloat*>(glMapBufferARB( GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB ));
GLfloat *data = reinterpret_cast<GLfloat*>(glMapBuffer( GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB ));
std::copy(vertexBuffer_.begin(), vertexBuffer_.end(), data);
glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
glUnmapBuffer(GL_ARRAY_BUFFER_ARB);
ACG::GLState::bindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
}
......
......@@ -224,8 +224,9 @@ void TextureNode::setTextureDataGL ( GLuint _textureId,
applyTextureParameters(_textureId);
bool mipmaps = mipmapping_globally_active_ && mipmapping_;
// Load the image
if ( mipmapping_globally_active_ && mipmapping_ )
if ( mipmaps )
tex->autogenerateMipMaps();
tex->setData( 0, // level
......@@ -234,7 +235,8 @@ void TextureNode::setTextureDataGL ( GLuint _textureId,
_height, // height (2^m)
_format, // format
_type, // type
_data ); // pointer to pixels
_data, // pointer to pixels
mipmaps); // mipmaps or not
// Unbind until we use it
ACG::GLState::bindTexture(GL_TEXTURE_2D,0);
......
......@@ -696,7 +696,7 @@ namespace GLSL {
* @param _name Name of the fragment output data
*/
void Program::bindFragDataLocation(unsigned int _index, const char *_name) {
glBindFragDataLocationEXT(this->m_programId, _index, _name);
glBindFragDataLocation(this->m_programId, _index, _name);
checkGLError2(_name);
}
......@@ -728,7 +728,7 @@ namespace GLSL {
* @return Fragment data location
*/
int Program::getFragDataLocation(const char *_name) {
int attributeLocation = glGetFragDataLocationEXT(this->m_programId, _name);
int attributeLocation = glGetFragDataLocation(this->m_programId, _name);
checkGLError2(_name);
return attributeLocation;
}
......@@ -740,7 +740,7 @@ namespace GLSL {
* @param _type Geometry type
*/
void Program::setGeometryInputType(GLint _type) {
glProgramParameteriEXT(this->m_programId, GL_GEOMETRY_INPUT_TYPE_EXT, _type);
glProgramParameteri(this->m_programId, GL_GEOMETRY_INPUT_TYPE_EXT, _type);
}
/** \brief Set output type of geometry
......@@ -750,7 +750,7 @@ namespace GLSL {
* @param _type Output geometry type
*/
void Program::setGeometryOutputType(GLint _type) {
glProgramParameteriEXT(this->m_programId, GL_GEOMETRY_OUTPUT_TYPE_EXT, _type);
glProgramParameteri(this->m_programId, GL_GEOMETRY_OUTPUT_TYPE_EXT, _type);
}
/** \brief Sets the maximum vertex output of the geometry shader
......@@ -760,7 +760,7 @@ namespace GLSL {
* @param _numVerticesOut Maximal number of vertices
*/
void Program::setGeometryVertexCount(GLint _numVerticesOut){
glProgramParameteriEXT(this->m_programId, GL_GEOMETRY_VERTICES_OUT_EXT, _numVerticesOut);
glProgramParameteri(this->m_programId, GL_GEOMETRY_VERTICES_OUT_EXT, _numVerticesOut);
}
......
Subproject commit bd3ec6a988d0d1349510bae112bb1bedb1fcecf0
Subproject commit 8396dceab1bc522368546889a3c750239061eadf
......@@ -207,72 +207,12 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
splitter_ = new QSplitter(Qt::Vertical,toolSplitter_);
stackedWidget_ = new QStackedWidget(splitter_);
OFGLFormat format = OFGLFormat::defaultFormat();
#ifdef ARCH_DARWIN
format.setStereo(false);
#else
format.setStereo(OpenFlipper::Options::stereo());
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
format.setAlphaBufferSize(8);
format.setStencilBufferSize(8);
format.setSamples(OpenFlipper::Options::samples());
#else
format.setAlpha(true);
format.setStencil(true);
format.setSampleBuffers(true);
#endif
// Construct GL context & widget
baseLayout_ = new QtMultiViewLayout;
baseLayout_->setContentsMargins(0,0,0,0);
// ===============================================================================
// Test context capabilities ...
// If we get stereo buffers, we use them .. which might disable multisampling
// If we don't have stereo, we disable it to not interfere with multisampling
// ===============================================================================
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
OFGLWidget* test = new OFGLWidget();
test->setFormat(format);
#else
OFGLWidget* test = new OFGLWidget(format);
#endif
if ( ! test->format().stereo() ) {
// std::cerr << "No stereo ... disabling stereo for real context!" << std::endl;
format.setStereo(false);
}/* else {
std::cerr << "Stereo found ok" << std::endl;
}*/
delete test;
if (OpenFlipper::Options::coreProfile()) {
#if QT_VERSION >= 0x050000
// request the highest OpenGL version
// QT 5 should gracefully provide the next highest available version
format.setVersion(4, 0);
format.setProfile(OFGLFormat::CoreProfile);
#else
format.setProfile(OFGLFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DeprecatedFunctions);
#endif
}
else {
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DeprecatedFunctions);
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 4))
if (OpenFlipper::Options::debug())
format.setOption(format.options() | QSurfaceFormat::DebugContext);
glWidget_ = new OFGLWidget();
glWidget_->setFormat(format);
glWidget_->makeCurrent();
#else
glWidget_ = new OFGLWidget(format, 0);
......
......@@ -100,17 +100,6 @@ void glViewer::startGLDebugLogger()
if (OpenFlipper::Options::debug())
{
delete glDebugLogger_;
//workaround for windows, because the DebugContext flag is discarded by QMainWindow show in core.cc
#ifdef WIN32
QOpenGLContext* ctx = QOpenGLContext::currentContext();
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
ctx->setFormat(format);
ctx->create();
QOffscreenSurface* surface = new QOffscreenSurface();
surface->create();
ctx->makeCurrent(surface);
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
glDebugLogger_ = new QOpenGLDebugLogger(this);
if (glDebugLogger_->initialize())
{
......
......@@ -77,7 +77,29 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
// Files
connect(pbReloadShaders,SIGNAL(clicked()),this,SLOT(slotReloadShaders()));
// OpenGL versions
VersionComboBox->clear();
VersionComboBox->addItem("4.6",QVariant::fromValue(QPair<int, int>(4,6)));
VersionComboBox->addItem("4.5",QVariant::fromValue(QPair<int, int>(4,5)));
VersionComboBox->addItem("4.4",QVariant::fromValue(QPair<int, int>(4,4)));
VersionComboBox->addItem("4.3",QVariant::fromValue(QPair<int, int>(4,3)));
VersionComboBox->addItem("4.2",QVariant::fromValue(QPair<int, int>(4,2)));
VersionComboBox->addItem("4.1",QVariant::fromValue(QPair<int, int>(4,1)));
VersionComboBox->addItem("4.0",QVariant::fromValue(QPair<int, int>(4,0)));
VersionComboBox->addItem("3.3",QVariant::fromValue(QPair<int, int>(3,3)));
VersionComboBox->addItem("3.2",QVariant::fromValue(QPair<int, int>(3,2)));
VersionComboBox->addItem("3.1",QVariant::fromValue(QPair<int, int>(3,1)));
VersionComboBox->addItem("3.0",QVariant::fromValue(QPair<int, int>(3,0)));
VersionComboBox->addItem("2.1",QVariant::fromValue(QPair<int, int>(2,1)));
VersionComboBox->addItem("2.0",QVariant::fromValue(QPair<int, int>(2,0)));
VersionComboBox->addItem("1.5",QVariant::fromValue(QPair<int, int>(1,5)));
VersionComboBox->addItem("1.4",QVariant::fromValue(QPair<int, int>(1,4)));
VersionComboBox->addItem("1.3",QVariant::fromValue(QPair<int, int>(1,3)));
VersionComboBox->addItem("1.2",QVariant::fromValue(QPair<int, int>(1,2)));
VersionComboBox->addItem("1.1",QVariant::fromValue(QPair<int, int>(1,1)));
VersionComboBox->addItem("1.0",QVariant::fromValue(QPair<int, int>(1,0)));
// Viewer Settings
connect( restrictFPS, SIGNAL(toggled(bool)), FPS, SLOT(setEnabled(bool)) );
connect( viewerList, SIGNAL(currentRowChanged(int)), this, SLOT(updateViewerSettings(int)) );
......@@ -270,6 +292,37 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
//OpenGL
samples_spinBox->setValue(OpenFlipper::Options::samples());
QPalette warning = samplesWarning->palette();
samplesWarning->setText(QString::number(QOpenGLContext::currentContext()->format().samples()));
if(OpenFlipper::Options::samples() != QOpenGLContext::currentContext()->format().samples())
warning.setColor(samplesWarning->foregroundRole(),Qt::red);
else
warning.setColor(samplesWarning->foregroundRole(),Qt::black);
samplesWarning->setPalette(warning);
VersionComboBox->setCurrentIndex( VersionComboBox->findData(QVariant::fromValue(OpenFlipper::Options::glVersion())));
QPalette version = versionWarning->palette();
versionWarning->setText(QString("%1.%2").arg(QOpenGLContext::currentContext()->format().version().first)
.arg(QOpenGLContext::currentContext()->format().version().second));
if(OpenFlipper::Options::glVersion() != QOpenGLContext::currentContext()->format().version())
version.setColor(versionWarning->foregroundRole(),Qt::red);
else
version.setColor(versionWarning->foregroundRole(),Qt::black);
versionWarning->setPalette(version);
QPalette profile = profileWarning->palette();
profileComboBox->setCurrentIndex(OpenFlipper::Options::coreProfile()?0:1);
if(QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile)
profileWarning->setText("Core");
if(QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CompatibilityProfile)
profileWarning->setText("Compatibility");
if(QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::NoProfile)
profileWarning->setText("None");
if(OpenFlipper::Options::coreProfile() && QOpenGLContext::currentContext()->format().profile() != QSurfaceFormat::CoreProfile)
profile.setColor(profileWarning->foregroundRole(),Qt::red);
else
profile.setColor(profileWarning->foregroundRole(),Qt::black);
profileWarning->setPalette(profile);
//Files
logFile->setText( OpenFlipperSettings().value("Core/Log/logFile").toString() );
......@@ -585,6 +638,8 @@ void OptionsWidget::slotApply() {
//OpenGL settings
OpenFlipperSettings().setValue("Core/OpenGL/Samples",samples_spinBox->value());
OpenFlipper::Options::glVersion(VersionComboBox->currentData().value<QPair<int,int>>());
OpenFlipper::Options::coreProfile(profileComboBox->currentIndex() == 0);
//Paths settings
OpenFlipperSettings().setValue("Core/File/MaxRecent",maxRecentBox->value() ) ;
......
This diff is collapsed.