diff --git a/CAVE/NOMADCaveT/src/main.cpp b/CAVE/NOMADCaveT/src/main.cpp index 7bc16c0d45b8188eb2150a96ddf226ace32a9413..ca47e7f749fdf09919734d9d331d862bbad9ae37 100644 --- a/CAVE/NOMADCaveT/src/main.cpp +++ b/CAVE/NOMADCaveT/src/main.cpp @@ -240,6 +240,7 @@ if (e!=GL_NO_ERROR) { eprintf ("OpenGL error after loading config file %d", e); error=-409; } + glGenTextures(2, textures); e=glGetError(); if (e!=GL_NO_ERROR) { @@ -398,6 +399,7 @@ bool er; else mvs=glm::scale(mvs, glm::vec3(globalscaling*scaling, globalscaling*scaling, globalscaling*scaling)); + matcubetrans=glm::translate(matcubetrans,glm::vec3(cubetrans[0], cubetrans[1], cubetrans[2])); glm::mat4 abcm (abc[0][0], abc[0][1], abc[0][2], 0, @@ -942,6 +944,15 @@ void sceneManager::RenderAtomBonds(const float *t) { GLenum e; if (numBonds) { + if ((e = glGetError()) != GL_NO_ERROR) + eprintf("Gl error at start of RenderAtomBonds, %d, %s\n", + e, gluErrorString(e)); + //rgh: glLineWidth > 1 returns invalid value according to new standard + //glLineWidth(bondThickness); + //if ((e = glGetError()) != GL_NO_ERROR) + // eprintf("Gl error after Render Atom bonds glLineWidth " + // "timestep =%d, bondThickness=%f: %d, %s\n", + // m_oldTime, bondThickness, e, gluErrorString(e)); glBindVertexArray(AtomTVAO[2]); if ((e = glGetError()) != GL_NO_ERROR) eprintf("Gl error after Render Atom bonds glBindVertexArray timestep =%d: %d, %s\n", m_oldTime, e, gluErrorString(e)); @@ -956,7 +967,8 @@ if (numBonds) { else glDrawElements(GL_LINES, numBonds[m_oldTime]-numBonds[m_oldTime-1], GL_UNSIGNED_INT, (void*)(sizeof(int)*numBonds[m_oldTime-1]) ); - + //glBindVertexArray(0); + //glLineWidth(1.0f); if ((e = glGetError()) != GL_NO_ERROR) eprintf("Gl error after Render Atom bonds timestep =%d: %d, %s\n", m_oldTime, e, gluErrorString(e)); } diff --git a/NOMADVRLib/ConfigFile.cpp b/NOMADVRLib/ConfigFile.cpp index 391dca70969e2a0b85bf6efd2ff2533bdc741fe2..c5546772d05b784501789902b83e8715496d88b1 100644 --- a/NOMADVRLib/ConfigFile.cpp +++ b/NOMADVRLib/ConfigFile.cpp @@ -85,15 +85,15 @@ std::vector<information> info; const char * loadConfigFileErrors[] = { "All Ok",//0 - "file could not be opened", //-1 - "unrecognized parameter",//-2 - "values with no previous iso", //-3 - "colours with no previous iso",//-4 - "translations with no previous correct iso",//-5 - "Missing isos and xyzfile",//-6 - "missing values",//-7 - "timesteps from config file and from atom file do not match",//-8, unused, now minimum is used - "isos parameter specified twice",//-9 + "File could not be opened", //-1 + "Unrecognized parameter",//-2 + "Values with no previous iso", //-3 + "Colours with no previous iso",//-4 + "Translations with no previous correct iso",//-5 + "Isos present but no timestep value given",//-6 + "Missing values",//-7 + "Timesteps from config file and from atom file do not match",//-8, unused, now minimum is used + "Isos parameter specified twice",//-9 "Error reading unit cell parameters", //-10 "Error reading repetitions",//-11 "Non-periodic, but repetitions requested", //-12 @@ -101,8 +101,8 @@ const char * loadConfigFileErrors[] = "Error loading config file",// -14 "Error reading atomglyph", //-15 "Error reading token", //-16 - "markers with no previous correct timesteps parameter", //-17 - "markercolours with no previous correct timesteps parameter", //-18 + "Markers with no previous correct timesteps parameter", //-17 + "Markercolours with no previous correct timesteps parameter", //-18 "Error reading atomcolour", // -19 "Error reading newatom", //-20 "Error loading xyz file, add 100 to see the error",//<-100 @@ -701,10 +701,10 @@ int loadConfigFile(const char * f) //verification and additional processing fclose(F); - /*if (ISOS == 0 && numAtoms==0) { - eprintf( "Missing isos and atomfile parameter\n"); + if (ISOS != 0 && TIMESTEPS==0) { + eprintf( "Isos requested, but no timesteps indicated\n"); return -6; - } */ + } if (ISOS !=0 && plyfiles[0] == 0) { eprintf( "Missing values parameter\n"); fclose(F); diff --git a/NOMADVRLib/TexturedShaders.cpp b/NOMADVRLib/TexturedShaders.cpp new file mode 100644 index 0000000000000000000000000000000000000000..55745d86b1dc09dbe2b035f4d660628c2df61ddd --- /dev/null +++ b/NOMADVRLib/TexturedShaders.cpp @@ -0,0 +1,46 @@ +/* +# Copyright 2016-2018 The NOMAD Developers Group + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. +*/ + +#include "TexturedShaders.h" + +const char * const TexturedShaders [] = { + + "render model", + + // vertex shader + "#version 410\n" + "uniform mat4 matrix;\n" + "layout(location = 0) in vec4 position;\n" + "layout(location = 1) in vec3 v3NormalIn;\n" + "layout(location = 2) in vec2 v2TexCoordsIn;\n" + "out vec2 v2TexCoord;\n" + "void main()\n" + "{\n" + " v2TexCoord = v2TexCoordsIn;\n" + " gl_Position = matrix * vec4(position.xyz, 1);\n" + "}\n", + + //fragment shader + "#version 410 core\n" + "uniform sampler2D diffuse;\n" + "in vec2 v2TexCoord;\n" + "out vec4 outputColor;\n" + "void main()\n" + "{\n" + " outputColor = texture( diffuse, v2TexCoord);\n" + "}\n", + nullptr + }; diff --git a/NOMADVRLib/TexturedShaders.h b/NOMADVRLib/TexturedShaders.h new file mode 100644 index 0000000000000000000000000000000000000000..d9e757c217ec26b330e5de10964bba9b73dec543 --- /dev/null +++ b/NOMADVRLib/TexturedShaders.h @@ -0,0 +1,17 @@ +/* +# Copyright 2016-2018 The NOMAD Developers Group + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. +*/ + +extern const char * const TexturedShaders []; diff --git a/OpenVR/TimestepData/hellovr_opengl_main.cpp b/OpenVR/TimestepData/hellovr_opengl_main.cpp index 41ebbad211ab2946736caa6165f65e04978d2e4d..63eacf80226bc07b5ce2d23f7e38398e10c1bfb7 100644 --- a/OpenVR/TimestepData/hellovr_opengl_main.cpp +++ b/OpenVR/TimestepData/hellovr_opengl_main.cpp @@ -61,6 +61,7 @@ #include "NOMADVRLib/TessShaders.h" #include "NOMADVRLib/UnitCellShaders.h" #include "NOMADVRLib/IsoShaders.h" +#include "NOMADVRLib/TexturedShaders.h" #include "NOMADVRLib/CompileGLShader.h" #include "NOMADVRLib/polyhedron.h" @@ -1326,31 +1327,9 @@ bool CMainApplication::CreateAllShaders() } m_unRenderModelProgramID = CompileGLShader( - "render model", - - // vertex shader - "#version 410\n" - "uniform mat4 matrix;\n" - "layout(location = 0) in vec4 position;\n" - "layout(location = 1) in vec3 v3NormalIn;\n" - "layout(location = 2) in vec2 v2TexCoordsIn;\n" - "out vec2 v2TexCoord;\n" - "void main()\n" - "{\n" - " v2TexCoord = v2TexCoordsIn;\n" - " gl_Position = matrix * vec4(position.xyz, 1);\n" - "}\n", - - //fragment shader - "#version 410 core\n" - "uniform sampler2D diffuse;\n" - "in vec2 v2TexCoord;\n" - "out vec4 outputColor;\n" - "void main()\n" - "{\n" - " outputColor = texture( diffuse, v2TexCoord);\n" - "}\n" - + TexturedShaders[SHADERNAME], + TexturedShaders[SHADERVERTEX], + TexturedShaders[SHADERFRAGMENT] ); m_nRenderModelMatrixLocation = glGetUniformLocation( m_unRenderModelProgramID, "matrix" ); if( m_nRenderModelMatrixLocation == -1 ) @@ -2420,6 +2399,8 @@ void CMainApplication::CleanDepthTexture () void CMainApplication::RenderInfo(const vr::Hmd_Eye &nEye) { int e; +if (info.size()==0) + return; glBindVertexArray(m_unInfoVAO); glActiveTexture( GL_TEXTURE0 ); glBindBuffer(GL_ARRAY_BUFFER, m_unInfoVertBuffer); @@ -2467,7 +2448,8 @@ for (int i = 0; i < info.size(); i++) { Matrix4 transform = GetCurrentViewProjectionMatrix(nEye)*trans*nt; glUniformMatrix4fv(m_nUnitCellMatrixLocation, 1, GL_FALSE, transform.get()); if ((e = glGetError()) != GL_NO_ERROR) - dprintf("Gl error after glUniform4fv 1 RenderUnitCell: %d, %s\n", e, gluErrorString(e)); + dprintf("Gl error after glUniform4fv 1 RenderInfo: %d, %s\n", + e, gluErrorString(e)); glUniform4fv(m_nUnitCellColourLocation, 1, infolinecolour);