marinos.giannoukakis Posted July 14, 2015 Share Posted July 14, 2015 Hi trying to build a C++ app with a custom particle system class and get a bunch of linking errors like the following, have been stressing over this for quite a bit an I ran out of ideas. I can't really understand the linking errors, but is certain that I am doing something fundamentally wrong here. Error 14 error LNK2019: unresolved external symbol "public: static int __cdecl GLExt::error(void)" (?error@GLExt@@SAHXZ) referenced in function "public: virtual void __cdecl Particles::init(void)" (?init@Particles@@UEAAXXZ) C:\Users\HLiX\Documents\unigine_project_1\source\ung_cpp_project_test.obj ung_cpp_project_test (Visual Studio 2010) Error 15 error LNK2019: unresolved external symbol __imp_glDrawArrays referenced in function "public: virtual void __cdecl Particles::render(void)" (?render@Particles@@UEAAXXZ) C:\Users\HLiX\Documents\unigine_project_1\source\ung_cpp_project_test.obj ung_cpp_project_test (Visual Studio 2010) Error 19 error LNK2001: unresolved external symbol "void (__cdecl* glDispatchCompute)(unsigned int,unsigned int,unsigned int)" (?glDispatchCompute@@3P6AXIII@ZEA) C:\Users\HLiX\Documents\unigine_project_1\source\ung_cpp_project_test.obj ung_cpp_project_test (Visual Studio 2010) essentially I can't call any of these functions.... can someone please point out what sort of huge mistakes I have done here.....? Link to comment
silent Posted July 15, 2015 Share Posted July 15, 2015 Hi Marinos, Could you please provide a minimal sample for reproduction? I'm afraid these information is not enough for debugging. We need to build your project first to get the more information. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
marinos.giannoukakis Posted July 15, 2015 Author Share Posted July 15, 2015 hi Silent, thanks again for the immediate response.... must admit that this contribution to the forum is vital... so here is the Class and its member functions... the code is def not correct and finished, also have not implemented my own update functions yet for the main(), but there seems to be already a problem with linking with the member functions.... and I can t further debug or correct wrongs if I don t get pass the linking errors.... #include <UnigineEngine.h> #include <UnigineConsole.h> #include <UnigineGame.h> #include <UnigineLightWorld.h> #include <UnigineMaterials.h> #include <UniginePlayerDummy.h> #include <UnigineWorld.h> #include <UnigineObjectMeshStatic.h> #include <UnigineType.h> #include <UnigineEditor.h> #include <UnigineShader.h> #include <UnigineMathLib.h> //#include "UnigineEngine.h" #include "UnigineApp.h" #include "Log.h" #include "GLShader.h" #include "GLTexture.h" #include "GLAppWindow.h" #include "GLFontTTF.h" //#include "DemoApp.h" #include "MathLib.h" //#include "App.h" //using namespace Unigine; /* */ class Particles { public: Particles(); virtual ~Particles(); virtual void init(); virtual void destroy(); //virtual void shutdown(); virtual void update(); virtual void render(); private: Font *font; GLShader *points_shader; GLShader *transform_shader; GLTexture *noise_texture; int width; int height; GLuint vertex_vao_id; GLuint vertex_vbo_id; protected: mat4 projection; // projection matrix mat4 modelview; // modelview matrix mat4 imodelview; // inverse modelview matrix mat4 modelviewprojection; // modelviewprojection matrix int pause; // pause flag int frame; // frame float time; // time }; /* */ void Particles::init() { //setTitle("GLInterop http://unigine.com/"); //font = new GLFontTTF("data/font.ttf"); points_shader = NULL; transform_shader = NULL; noise_texture = NULL; width = 1024; height = 1024; time = 0; vertex_vao_id = 0; vertex_vbo_id = 0; GLExt::error(); } /* */ /*void Particles::shutdown() { delete font; delete points_shader; delete transform_shader; delete noise_texture; }*/ /* */ void Particles::destroy() { font->destroy(); points_shader->destroy(); transform_shader->destroy(); noise_texture->destroy(); delete points_shader; delete transform_shader; delete noise_texture; points_shader = NULL; transform_shader = NULL; noise_texture = NULL; vertex_vao_id = 0; vertex_vbo_id = 0; } /* */ void Particles::update() { } /* */ void Particles::render() { //gets from game class Unigine::App *app = Unigine::App::get(); //float time = game->getTime(); float ifps = app->getIFps(); float fps = app->getFps(); time += ifps; if(points_shader == NULL) { points_shader = new GLShader("shaders/points.shader"); transform_shader = new GLShader("shaders/transform.shader"); noise_texture = new GLTexture("data/noise.png",GLTexture::FILTER_LINEAR); } // create vertex buffer if(vertex_vao_id == 0) { glGenBuffers(1,&vertex_vbo_id); glBindBuffer(GL_SHADER_STORAGE_BUFFER,vertex_vbo_id); glBufferData(GL_SHADER_STORAGE_BUFFER,sizeof(vec4) * width * height,NULL,GL_DYNAMIC_DRAW); glBindBuffer(GL_SHADER_STORAGE_BUFFER,0); glGenVertexArrays(1,&vertex_vao_id); glBindVertexArray(vertex_vao_id); glBindBuffer(GL_ARRAY_BUFFER,vertex_vbo_id); glVertexAttribPointer(1,4,GL_UNSIGNED_BYTE,1,sizeof(vec4),(void*)(sizeof(float) * 3)); glVertexAttribPointer(0,3,GL_FLOAT,0,sizeof(vec4),(void*)(0)); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glBindVertexArray(0); } glClearColor(0.0f,0.0f,0.0f,1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // run kernel transform_shader->bind(); transform_shader->setParameterInt1("width",width); transform_shader->setParameterInt1("height",height); transform_shader->setParameterFloat1("time",time * 8.0f); noise_texture->bind(0); glBindBufferBase(GL_SHADER_STORAGE_BUFFER,0,vertex_vbo_id); glDispatchCompute(Math::udiv(width,16),Math::udiv(height,16),1); glBindBufferBase(GL_SHADER_STORAGE_BUFFER,0,0); transform_shader->unbind(); // draw points points_shader->bind(); Unigine::Game *game = Unigine::Game::get(); Unigine::PlayerPtr *p0; *p0 = game->getPlayer(); // create player Unigine::PlayerDummyPtr playerDummy = Unigine::PlayerDummy::create(*p0); //Unigine::Player *player; //maybe don t need this //player = playerDummy->getPlayer(); // there is an error here can t use Unigine::dmat4 _modelview = playerDummy->getModelview(); Unigine::mat4 _projection = playerDummy->getProjection(); modelview = mat4(vec4(_modelview.m00, _modelview.m01, _modelview.m02, 0.0),vec4(_modelview.m03, _modelview.m10, _modelview.m11, 0.0), vec4(_modelview.m12, _modelview.m13, _modelview.m20, 0.0), vec4(_modelview.m21, _modelview.m22, _modelview.m23, 0.0)); //this is wrong fix later //modelview = lookAt(camera_position,camera_position + x,vec3(0.0f,0.0f,1.0f)); imodelview = inverse(modelview); modelviewprojection = projection * modelview; points_shader->setParameterFloat("mvp",modelviewprojection,16); glBindVertexArray(vertex_vao_id); glBindBuffer(GL_ARRAY_BUFFER,vertex_vbo_id); glDrawArrays(GL_POINTS,0,width * height); glBindBuffer(GL_ARRAY_BUFFER,0); glBindVertexArray(0); points_shader->unbind(); // info font->enable(app->getWidth(),app->getHeight()); font->printf(10,10,32,FONT_BROWN"FPS:"FONT_DEFAULT" %.1f",fps); font->printf(10,42,24,"Memory: %.1fMb/s", sizeof(vec4) * width * height * fps / 1024.0f / 1024.0f); font->disable(); GLExt::error(); } Link to comment
marinos.giannoukakis Posted July 15, 2015 Author Share Posted July 15, 2015 would you prefer me posting the VS proj....? Link to comment
marinos.giannoukakis Posted July 15, 2015 Author Share Posted July 15, 2015 in essence as I posted yesterday on a post in the shaders forum, it would be really useful if we had a compute shader working sample... especially now that these shaders have started been used more widely in games for simulations and such... Link to comment
silent Posted July 16, 2015 Share Posted July 16, 2015 Hi Marinos, would you prefer me posting the VS proj....? Yes, it is better to provide the whole VS proj and modified files with a small description how to build your sample. Thank you! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
marinos.giannoukakis Posted July 16, 2015 Author Share Posted July 16, 2015 I ll send it by email silent, is that ok....? Link to comment
Recommended Posts