Closed Eckart23 closed 8 years ago
Hi could You please paste the whole code? How is for example the ShapeWrapperPtr defined ?
Hi, thanks for your reply! I'm trying to set up code from this project: https://github.com/OculusRiftInAction/OculusRiftInAction, which uses oglplus. My errors occurs in the attached code. Thanks in advance!
Resource SCENE_IMAGES_DK1[2] = { Resource::IMAGES_TUSCANY_UNDISTORTED_LEFT_DK1_PNG, Resource::IMAGES_TUSCANY_UNDISTORTED_RIGHT_DK1_PNG };
Resource SCENE_IMAGES_DK2[2] = { Resource::IMAGES_TUSCANY_UNDISTORTED_LEFT_DK2_PNG, Resource::IMAGES_TUSCANY_UNDISTORTED_RIGHT_DK2_PNG };
class UndistortedExample : public RiftGlfwApp {
protected: TexturePtr textures[2]; ProgramPtr program; ShapeWrapperPtr shape;
public: virtual ~UndistortedExample() { }
void initGl() { using namespace oglplus; RiftGlfwApp::initGl(); Context::Disable(Capability::Blend); Context::Disable(Capability::DepthTest); Context::Disable(Capability::CullFace);
program = oria::loadProgram(
Resource::SHADERS_TEXTURED_VS,
Resource::SHADERS_TEXTURED_FS);
shape = ShapeWrapperPtr(new shapes::ShapeWrapper({ "Position", "TexCoord" }, shapes::Plane(
Vec3f(1, 0, 0),
Vec3f(0, 1, 0)
), *program));
Resource * sceneImages = SCENE_IMAGES_DK2;
if (hmd->Type == ovrHmd_DK1) {
sceneImages = SCENE_IMAGES_DK1;
}
for_each_eye([&](ovrEyeType eye) {
textures[eye] = oria::load2dTexture(sceneImages[eye]);
});
}
virtual void shutdownGl() { program.reset(); shape.reset(); for_each_eye([&](ovrEyeType eye) { textures[eye].reset(); }); RiftGlfwApp::shutdownGl(); }
void draw() { using namespace oglplus;
DefaultFramebuffer().Bind(Framebuffer::Target::Draw);
Context::Clear().ColorBuffer();
for_each_eye([&](ovrEyeType eye) {
renderEye(eye);
});
}
void renderEye(ovrEyeType eye) { viewport(eye); // Stacks::modelview().identity().rotate(HALF_PI, Vectors::X_AXIS); textures[eye]->Bind(oglplus::Texture::Target::_2D); oria::renderGeometry(shape, program); } };
Resource SCENE_IMAGES_DK1[2] = { Resource::IMAGES_TUSCANY_UNDISTORTED_LEFT_DK1_PNG, Resource::IMAGES_TUSCANY_UNDISTORTED_RIGHT_DK1_PNG };
Resource SCENE_IMAGES_DK2[2] = { Resource::IMAGES_TUSCANY_UNDISTORTED_LEFT_DK2_PNG, Resource::IMAGES_TUSCANY_UNDISTORTED_RIGHT_DK2_PNG };
class UndistortedExample : public RiftGlfwApp {
protected: TexturePtr textures[2]; ProgramPtr program; ShapeWrapperPtr shape;
public: virtual ~UndistortedExample() { }
void initGl() { using namespace oglplus; RiftGlfwApp::initGl(); Context::Disable(Capability::Blend); Context::Disable(Capability::DepthTest); Context::Disable(Capability::CullFace);
program = oria::loadProgram(
Resource::SHADERS_TEXTURED_VS,
Resource::SHADERS_TEXTURED_FS);
shape = ShapeWrapperPtr(new shapes::ShapeWrapper({ "Position", "TexCoord" }, shapes::Plane(
Vec3f(1, 0, 0),
Vec3f(0, 1, 0)
), *program));
Resource * sceneImages = SCENE_IMAGES_DK2;
if (hmd->Type == ovrHmd_DK1) {
sceneImages = SCENE_IMAGES_DK1;
}
for_each_eye([&](ovrEyeType eye) {
textures[eye] = oria::load2dTexture(sceneImages[eye]);
});
}
virtual void shutdownGl() { program.reset(); shape.reset(); for_each_eye([&](ovrEyeType eye) { textures[eye].reset(); }); RiftGlfwApp::shutdownGl(); }
void draw() { using namespace oglplus;
DefaultFramebuffer().Bind(Framebuffer::Target::Draw);
Context::Clear().ColorBuffer();
for_each_eye([&](ovrEyeType eye) {
renderEye(eye);
});
}
void renderEye(ovrEyeType eye) { viewport(eye); // Stacks::modelview().identity().rotate(HALF_PI, Vectors::X_AXIS); textures[eye]->Bind(oglplus::Texture::Target::_2D); oria::renderGeometry(shape, program); } };
RUN_OVR_APP(UndistortedExample)
OK, could You check how is the OGLPLUS_NO_INITIALIZER_LISTS
preprocessor symbol defined?
defined(BOOST_NO_INITIALIZER_LISTS)
Yeah, I know :) but what is the actual value defined when you compile the source. Either it it defined as 1
and then the initializer list constructors are undefined or it is 0
and there is some other problem. Maybe GLchar
is something different than char
on MacOSX ?
When I compile it, it is defined as 1.
OK, this means that the detection of support for initializer lists for some reason thought that initializer lists don't work properly. You can try to #define OGLPLUS_NO_INITIALIZER_LISTS 0
before including oglplus headers to manually enable initialize_list-related feature.
You could also try to compile the file ./config/cpp/has_INITIALIZER_LISTS.cpp
to see why the compiler failed to detect support for ILs.
HTH
Unfortunatly, even with doing #define OGLPLUS_NO_INITIALIZER_LISTS 0 the program compiles but then crashes. I have done ./config/cpp/has_INITIALIZER_LISTS.cpp and got:
./config/cpp/has_INITIALIZER_LISTS.cpp: line 1: /Applications: is a directory
./config/cpp/has_INITIALIZER_LISTS.cpp: line 2: CHANGELOG: command not found
./config/cpp/has_INITIALIZER_LISTS.cpp: line 3: syntax error near unexpected token (' ./config/cpp/has_INITIALIZER_LISTS.cpp: line 3:
* Software License, Version 1.0. (See accompanying file'
Hmm .. You have to compile the ./config/cpp/has_INITIALIZER_LISTS.cpp
file with the compiler.
Oh yes, obviously. This tells me:
./config/cpp/has_INITIALIZER_LISTS.cpp:12:21: error: expected expression
std::vector
Did You also specify the -std=c++11 option to the compiler?
Yes, it seems to give me an empty output.
And if You manually define OGLPLUS_NO_INITIALIZER_LISTS
to 0
then the program crashes where? (You for example dereference the program
pointer, is it valid?)
It crashes at this position:
ObjectName(const ObjectName& that)
OGLPLUS_NOEXCEPT(true)
: _name(that._name)
{ }
in the name_tpl.hpp file. I have not yet dereferenced the program pointer.
Could You step through it in a debugger and see in what context is that ObjectName
constructor called ?
With the debugger I stepped back to:
shape = ShapeWrapperPtr(new shapes::ShapeWrapper({ "Position", "TexCoord" }, shapes::Plane( Vec3f(1, 0, 0), Vec3f(0, 1, 0) ), *program));
Then the *program
must have been dereferenced, since the {"Position", "TexCoord"}
is an initializer list, shapes::Plane
does not store any internal object which would have an ObjectName
and the third argument is the pointer and all arguments must be evaluated prior to calling the ShapeWrapper
constructor.
Yes, this was the mistake. It's now running perfectly! Many thanks for your friendly help!
No problem! I'm glad it works.
When using this line "shape = ShapeWrapperPtr(new shapes::ShapeWrapper" , I get the error: no matching constructor for initialization of 'shapes::ShapeWrapper'. In the wrapper.hpp, the error says that the candidate constructor is not viable because the conversion of initiazer list argument to const GLchar\ is not possible. I'm compiling on osx 10.11. with the xcode standard compiler. Do you know why I get this error?