Enabling an extension on a Three.js shader - glsl

How can I enable an extension on a Three.js shader?
My code so far:
getting extension:
var domElement = document.createElement( 'canvas' );
var gl = domElement.getContext('webgl') || domElement.getContext('experimental-webgl');
gl.getExtension('OES_standard_derivatives');
on my shader:
fragmentShader: [
"#extension GL_OES_standard_derivatives : enable",
"code..."
]...
The console output:
WARNING: 0:26: extension 'GL_OES_standard_derivatives' is not supported
ERROR: 0:32: 'dFdx' : no matching overloaded function found
ERROR: 0:32: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
ERROR: 0:33: 'dFdy' : no matching overloaded function found
ERROR: 0:33: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
After reading this issue on github, I tried this example: From http://jsfiddle.net/VJca4/ I get these errors
WARNING: 0:27: extension 'GL_OES_standard_derivatives' is not supported
ERROR: 0:30: '=' : cannot convert from 'const mediump float' to '2-component vector of float'
ERROR: 0:31: 'dFdx' : no matching overloaded function found
ERROR: 0:31: '=' : cannot convert from 'const mediump float' to '2-component vector of float'

You should also be able to do this:
renderer.context.getExtension('OES_standard_derivatives');

Found the error. You have to use the renderer's dom element:
var gl = renderer.domElement.getContext('webgl') ||
renderer.domElement.getContext('experimental-webgl');
gl.getExtension('OES_standard_derivatives');

Related

error C2664 - cannot convert parameter 1 from 'initializer-list' to 'const QList<QCommandLineOption> &'

I downloaded some code and run it in VS2013+QT5.4, there is code like this:
parser.addOptions({
{ "nogui", QString("Using command line arguments, do not show GUI.") },
{ { "p", "path" }, QString("Path for job files or shape files."), QString("path") },
});
and I got an error:
error C2664 - cannot convert parameter 1 from 'initializer-list' to 'const QList<QCommandLineOption> &'
It seems about a VS problem of C++11?...and I wonder how to fix it?

glUniform3fv not working OpenGL

I'm working on a piece of code in OpenGL.
I'm getting the following error message while trying to compile:
MyGLWidget.cpp: In member function ‘virtual void MyGLWidget::initializeGL()’:
MyGLWidget.cpp:30:38: error: cannot convert ‘glm::vec3 {aka glm::tvec3<float, (glm::precision)0u>}’ to ‘const GLfloat* {aka const float*}’ in argument passing
MyGLWidget.cpp:31:39: error: cannot convert ‘glm::vec3 {aka glm::tvec3<float, (glm::precision)0u>}’ to ‘const GLfloat* {aka const float*}’ in argument passing
I have declared these locations in MyGLWidget.h as follows:
GLuint llumLoc, focusLoc;
And have initialize them in MyGLWidget.cpp as:
llumLoc = glGetUniformLocation (program->programId(), "llumAmbient");
focusLoc = glGetUniformLocation (program->programId(), "posFocus");
"llumAmbient" and "posFocus" are uniforms in my vertex shader:
uniform vec3 llumAmbient;
uniform vec3 posFocus;
I get the mentioned error message while trying to call the following code inside of MyGLWidget::initializeGL
glUniform3fv(llumLoc, 1, glm::vec3(0.2));
glUniform3fv(focusLoc, 1, glm::vec3(1.0));
Obviously, I've tried to follow the documentation at www.opengl.org and glm.g-truc.net/0.9.2/api/a00001.html, but I just can't see what's wrong with this code...
Actually, I just found out today that there's a cleaner and more straight forward way. Simply:
glUniform3fv(focusLoc, 1, &v[0]);
No need to import value_ptr.
You need to give a pointer to the vector, not the vector itself. For example:
glm::vec3 v(1.0f);
glUniform3fv(focusLoc, 1, glm::value_ptr(&v[0]));

Compiling SQLite with Visual Studio C++ 2013 Throws error for .c file

I have added sqlite3.c file into my project.
And #include. Here is the code:
#include <sqlite3.h>
using namespace std;
int main()
{
return 0;
}
I compile the program and it throws the following error:
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(15705): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(19741): error C2440: '=' : cannot convert from 'void *' to 'sqlite3_mutex *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(20665): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(20677): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21142): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21256): error C2440: '=' : cannot convert from 'void *' to 'char *'
1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast
1>..\..\..\..\..\..\..\libraries\sqlite-amalgamation-3080702\sqlite3.c(21411): error C2440: '=' : cannot convert from 'void *' to 'char *'
But there is no error that a header or file is not found. Everything is found and the errors are just outputted above
I have found the solution. I compiled the C code as C++, but changing it was not enough.
I write it for future visitors:
First, I had to change file's (ONLY FILE) property. Right-click on the file and select properties, under the C/C++, select Advanced and then select Compile As and set it to C (neither default nor C++).
Then, you should make sure that your .c file is compiled without clr. Well, to do that, under the same C/C++ set of menu, select "Common Langugae Runtime Support" and set it to No Support....
I'm using Visual Studio 17 and I would add to this, find the settings for "Precompiled Header" and set that to "Not Using Precompiled Headers".

error C2440 and functors

maybe you would know, I get an error:
error C2440: 'initializing' : cannot convert from 'int'
Conversion from integral type to pointer type requires reinterpret_cast
It goes to ' file in MS VS 2010 folder:
template<class _Other1,
class _Other2>
_Pair_base(_Other1&& _Val1, _Other2&& _Val2)
: first(_STD forward<_Other1>(_Val1)),
second(_STD forward<_Other2>(_Val2))
{ // construct from moved values
}
I was looking for different solutions but could not find a correct one.
The error says
'initializing' : cannot convert from 'int' to 'EnterFunctor *'
The only part of your code you share is
functors.push_back(make_pair(sessionStartFunc,
pair<EnterFunctor*, ExitFunctor*>(NULL,sessionStartExit)));
If NULL is #defined as 0 this gives you an int but you promised a pair of pointers, so as the next line of the error says you can use a cast to make NULL the right type of pointer.

Cannot convert from 'overloaded-function' to 'QLabel *'?

So, I am trying to use the following code to pass an object to a function in Qt, then convert it to a QLabel for further processing (it's part of an animation sequence):
void myAnimation(QObject* label)
{
QLabel *lbl = qobject_cast<QLabel*>label;
//more code.....
}
Yet, whenever I try to compile, I get the following two errors:
error: C2440: 'initializing' : cannot convert from 'overloaded-function' to 'QLabel *'
Context does not allow for disambiguation of overloaded function
and
error: C2146: syntax error : missing ';' before identifier 'label'
Why isn't my code working? Any help is appreciated. Thank you!
Try:
QLabel *lbl = qobject_cast<QLabel*>(label);
// ^ ^