daw42 / glslcookbook

Example code for the OpenGL Shading Language Cookbook - 2nd Edition (3rd Edition now available)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when running some examples

TonderaiZR opened this issue · comments

Hello

Hello does any one what this means.

genType glm::inversesqrt(const genType&) [with genType = float]: Assertion `x > genType(0)' failed.
Aborted (core dumped)

I got the same runtime error when using latest glm - 0.9.4.6, when changed to - glm-0.9.3.4 it worked properly.

That's odd. I'll see if I can reproduce this. It should work with the latest versions of GLM. It's probably a simple fix.

I believe I have tracked this down. In vboteapot.cpp, patches 3 and 5 seem to cause the error. In teapotdata.h these patches are the only ones with repeated numbers (indices). This causes a zero vector to appear in VBOTeapot::evaluateNormal and causing the cross product to generate another zero vector, causing a divide by zero within the normalization in the code return glm::normalize( glm::cross( du, dv ) );

I was planning to change to another versión of glm but if you solved issue please update code on github.

Thanks.

Thanks dangets! I've merged your fix (#12).

Thanks dangets/daw42! this works for me!
I had this before:

mesh->normals[v] = glm::normalize(mesh->normals[v]);

I fix it with:

    if(glm::length(mesh->normals[v])!=0.0f){
        mesh->normals[v] = glm::normalize(mesh->normals[v]);
    }else{
        mesh->normals[v] = glm::vec3(0.0, 0.0, 0.0);
    }