Commit e9f9cd7f authored by Ruben Garcia Hernndez's avatar Ruben Garcia Hernndez

Verify that timesteps parameter is present if isos are indicated in the config file.

Move TexturedShaders to NOMADVRLib (now used both by OpenVR and CAVE).
parent a899b46e
...@@ -240,6 +240,7 @@ if (e!=GL_NO_ERROR) { ...@@ -240,6 +240,7 @@ if (e!=GL_NO_ERROR) {
eprintf ("OpenGL error after loading config file %d", e); eprintf ("OpenGL error after loading config file %d", e);
error=-409; error=-409;
} }
glGenTextures(2, textures); glGenTextures(2, textures);
e=glGetError(); e=glGetError();
if (e!=GL_NO_ERROR) { if (e!=GL_NO_ERROR) {
...@@ -398,6 +399,7 @@ bool er; ...@@ -398,6 +399,7 @@ bool er;
else else
mvs=glm::scale(mvs, glm::vec3(globalscaling*scaling, mvs=glm::scale(mvs, glm::vec3(globalscaling*scaling,
globalscaling*scaling, globalscaling*scaling)); globalscaling*scaling, globalscaling*scaling));
matcubetrans=glm::translate(matcubetrans,glm::vec3(cubetrans[0], matcubetrans=glm::translate(matcubetrans,glm::vec3(cubetrans[0],
cubetrans[1], cubetrans[2])); cubetrans[1], cubetrans[2]));
glm::mat4 abcm (abc[0][0], abc[0][1], abc[0][2], 0, glm::mat4 abcm (abc[0][0], abc[0][1], abc[0][2], 0,
...@@ -942,6 +944,15 @@ void sceneManager::RenderAtomBonds(const float *t) ...@@ -942,6 +944,15 @@ void sceneManager::RenderAtomBonds(const float *t)
{ {
GLenum e; GLenum e;
if (numBonds) { 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]); glBindVertexArray(AtomTVAO[2]);
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error after Render Atom bonds glBindVertexArray timestep =%d: %d, %s\n", m_oldTime, e, gluErrorString(e)); eprintf("Gl error after Render Atom bonds glBindVertexArray timestep =%d: %d, %s\n", m_oldTime, e, gluErrorString(e));
...@@ -956,7 +967,8 @@ if (numBonds) { ...@@ -956,7 +967,8 @@ if (numBonds) {
else else
glDrawElements(GL_LINES, numBonds[m_oldTime]-numBonds[m_oldTime-1], GL_UNSIGNED_INT, glDrawElements(GL_LINES, numBonds[m_oldTime]-numBonds[m_oldTime-1], GL_UNSIGNED_INT,
(void*)(sizeof(int)*numBonds[m_oldTime-1]) ); (void*)(sizeof(int)*numBonds[m_oldTime-1]) );
//glBindVertexArray(0);
//glLineWidth(1.0f);
if ((e = glGetError()) != GL_NO_ERROR) if ((e = glGetError()) != GL_NO_ERROR)
eprintf("Gl error after Render Atom bonds timestep =%d: %d, %s\n", m_oldTime, e, gluErrorString(e)); eprintf("Gl error after Render Atom bonds timestep =%d: %d, %s\n", m_oldTime, e, gluErrorString(e));
} }
......
...@@ -85,15 +85,15 @@ std::vector<information> info; ...@@ -85,15 +85,15 @@ std::vector<information> info;
const char * loadConfigFileErrors[] = const char * loadConfigFileErrors[] =
{ {
"All Ok",//0 "All Ok",//0
"file could not be opened", //-1 "File could not be opened", //-1
"unrecognized parameter",//-2 "Unrecognized parameter",//-2
"values with no previous iso", //-3 "Values with no previous iso", //-3
"colours with no previous iso",//-4 "Colours with no previous iso",//-4
"translations with no previous correct iso",//-5 "Translations with no previous correct iso",//-5
"Missing isos and xyzfile",//-6 "Isos present but no timestep value given",//-6
"missing values",//-7 "Missing values",//-7
"timesteps from config file and from atom file do not match",//-8, unused, now minimum is used "Timesteps from config file and from atom file do not match",//-8, unused, now minimum is used
"isos parameter specified twice",//-9 "Isos parameter specified twice",//-9
"Error reading unit cell parameters", //-10 "Error reading unit cell parameters", //-10
"Error reading repetitions",//-11 "Error reading repetitions",//-11
"Non-periodic, but repetitions requested", //-12 "Non-periodic, but repetitions requested", //-12
...@@ -101,8 +101,8 @@ const char * loadConfigFileErrors[] = ...@@ -101,8 +101,8 @@ const char * loadConfigFileErrors[] =
"Error loading config file",// -14 "Error loading config file",// -14
"Error reading atomglyph", //-15 "Error reading atomglyph", //-15
"Error reading token", //-16 "Error reading token", //-16
"markers with no previous correct timesteps parameter", //-17 "Markers with no previous correct timesteps parameter", //-17
"markercolours with no previous correct timesteps parameter", //-18 "Markercolours with no previous correct timesteps parameter", //-18
"Error reading atomcolour", // -19 "Error reading atomcolour", // -19
"Error reading newatom", //-20 "Error reading newatom", //-20
"Error loading xyz file, add 100 to see the error",//<-100 "Error loading xyz file, add 100 to see the error",//<-100
...@@ -701,10 +701,10 @@ int loadConfigFile(const char * f) ...@@ -701,10 +701,10 @@ int loadConfigFile(const char * f)
//verification and additional processing //verification and additional processing
fclose(F); fclose(F);
/*if (ISOS == 0 && numAtoms==0) { if (ISOS != 0 && TIMESTEPS==0) {
eprintf( "Missing isos and atomfile parameter\n"); eprintf( "Isos requested, but no timesteps indicated\n");
return -6; return -6;
} */ }
if (ISOS !=0 && plyfiles[0] == 0) { if (ISOS !=0 && plyfiles[0] == 0) {
eprintf( "Missing values parameter\n"); eprintf( "Missing values parameter\n");
fclose(F); fclose(F);
......
/*
# 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
};
/*
# 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 [];
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "NOMADVRLib/TessShaders.h" #include "NOMADVRLib/TessShaders.h"
#include "NOMADVRLib/UnitCellShaders.h" #include "NOMADVRLib/UnitCellShaders.h"
#include "NOMADVRLib/IsoShaders.h" #include "NOMADVRLib/IsoShaders.h"
#include "NOMADVRLib/TexturedShaders.h"
#include "NOMADVRLib/CompileGLShader.h" #include "NOMADVRLib/CompileGLShader.h"
#include "NOMADVRLib/polyhedron.h" #include "NOMADVRLib/polyhedron.h"
...@@ -1326,31 +1327,9 @@ bool CMainApplication::CreateAllShaders() ...@@ -1326,31 +1327,9 @@ bool CMainApplication::CreateAllShaders()
} }
m_unRenderModelProgramID = CompileGLShader( m_unRenderModelProgramID = CompileGLShader(
"render model", TexturedShaders[SHADERNAME],
TexturedShaders[SHADERVERTEX],
// vertex shader TexturedShaders[SHADERFRAGMENT]
"#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"
); );
m_nRenderModelMatrixLocation = glGetUniformLocation( m_unRenderModelProgramID, "matrix" ); m_nRenderModelMatrixLocation = glGetUniformLocation( m_unRenderModelProgramID, "matrix" );
if( m_nRenderModelMatrixLocation == -1 ) if( m_nRenderModelMatrixLocation == -1 )
...@@ -2420,6 +2399,8 @@ void CMainApplication::CleanDepthTexture () ...@@ -2420,6 +2399,8 @@ void CMainApplication::CleanDepthTexture ()
void CMainApplication::RenderInfo(const vr::Hmd_Eye &nEye) void CMainApplication::RenderInfo(const vr::Hmd_Eye &nEye)
{ {
int e; int e;
if (info.size()==0)
return;
glBindVertexArray(m_unInfoVAO); glBindVertexArray(m_unInfoVAO);
glActiveTexture( GL_TEXTURE0 ); glActiveTexture( GL_TEXTURE0 );
glBindBuffer(GL_ARRAY_BUFFER, m_unInfoVertBuffer); glBindBuffer(GL_ARRAY_BUFFER, m_unInfoVertBuffer);
...@@ -2467,7 +2448,8 @@ for (int i = 0; i < info.size(); i++) { ...@@ -2467,7 +2448,8 @@ for (int i = 0; i < info.size(); i++) {
Matrix4 transform = GetCurrentViewProjectionMatrix(nEye)*trans*nt; Matrix4 transform = GetCurrentViewProjectionMatrix(nEye)*trans*nt;
glUniformMatrix4fv(m_nUnitCellMatrixLocation, 1, GL_FALSE, transform.get()); glUniformMatrix4fv(m_nUnitCellMatrixLocation, 1, GL_FALSE, transform.get());
if ((e = glGetError()) != GL_NO_ERROR) 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); glUniform4fv(m_nUnitCellColourLocation, 1, infolinecolour);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment