QtCreator Autocomplete Not Showing Arguments For OpenGL Functions?
-
Hi, I'm using QtCreator for my C++ and OpenGL development and it seems that it can't complete arguments for opengl functions?
@#include <GL/glew.h>
#include <GL/glfw.h>@I'm using GLFW and GLEW, and this is how I include them into my project. My programs that I create in C++ and OpenGL compile fine, just that there's no argument completion for GLEW. I made a similar post about this in StackOverflow (http://stackoverflow.com/questions/15561048/opengl-alternatives-to-glew-that-has-arguments-defined-or-a-solution-to-it) and I learned that the parser can't parse through the #defines and function pointers/macros.
So, I switched to QtCreator hoping for some better results but it seems that I can't get any argument completion with QtCreator.
Thanks.
EDIT: I'm on Arch Linux x64
-
After doing some research, it seems that function pointers aren't the problem, but the two or three-level abstraction introduced by macros. That means it stops resolving after it finds the first macro, i.e it treats glGetBuffer as GLEW_GET_FUN(__glewBindBuffer), which it doesn't parse recursively in order to get to typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer). And the parser may or may not be able to handle the typedef either.
Is there any way that the QtCreator's parser be able to do this? Visual Studio does this and gives argument completion, but I can't use it because I'm working on Linux and not on Windows.
-
Native parser doesn't show hints for macro, but ClangCodeModel does. Try this:
https://aur.archlinux.org/packages/qtcreator-clang-git/
Note that plugin is experimental.
-
[quote author="sergey-shambir" date="1364581997"]Native parser doesn't show hints for macro, but ClangCodeModel does. Try this:
https://aur.archlinux.org/packages/qtcreator-clang-git/
Note that plugin is experimental.[/quote]
The AUR is not updated, which gave me errors as I explained in the comments, so I can't test out the Clang Code Model.
EDIT: Also, it says "Project ERROR: Unknown module(s) in QT: script" when running qmake -r
-
Thanks! I've updated pkgbuild.
-
[quote author="sergey-shambir" date="1364594312"]Thanks! I've updated pkgbuild.[/quote]
Still doesn't work for some reason, I get
@fatal: Cannot update paths and switch to branch 'clang_mar2013' at the same time.
Did you intend to checkout 'origin/clang_mar2013' which can not be resolved as commit?@and when I rebuild (with same PKGBUILD), it goes to compile and build qtcreator but then it gives me the error of this:
@make[2]: Entering directory
/tmp/yaourt-tmp-joe/aur-qtcreator-clang-git/src/build/src/libs' cd utils/ && ( test -f Makefile || /usr/bin/qmake /tmp/yaourt-tmp-joe/aur-qtcreator-clang-git/src/qt-creator/src/libs/utils/utils.pro -o Makefile ) && make -f Makefile Project ERROR: Unknown module(s) in QT: script make[2]: *** [sub-utils-make_first-ordered] Error 3 make[2]: Leaving directory
/tmp/yaourt-tmp-joe/aur-qtcreator-clang-git/src/build/src/libs'
make[1]: *** [sub-libs-make_first-ordered] Error 2
make[1]: Leaving directory `/tmp/yaourt-tmp-joe/aur-qtcreator-clang-git/src/build/src'
make: *** [sub-src-make_first-ordered] Error 2@ -
Updated again, I'd pointed wrong branch first. Thanks for patience.
-
[quote author="sergey-shambir" date="1364597789"]Updated again, I'd pointed wrong branch first. Thanks for patience.[/quote]
Thanks, but I still get the latter problem, where it says "Project ERROR: Unknown module(s) in QT: script" when compiling. I think it's because it's trying to use QT5 and the code is in QT4 or vice versa.
-
Hi, I added another comment to the AUR, which is the solution to the problem, could you please update it again? It's still compiling as we speak so I didn't get to test it yet.
EDIT: So it compiled, but when I opened it and tried to autocomplete the macro, (example: glBindBuffer), it still didn't give me argument completion.
EDIT2: Can you see if it works on your side? A simple application would be this:
@#include <GL/glew.h>
#include <GL/glfw.h>int main() {
glfwInit();
glfwOpenWindow(1024, 768, 0, 0, 0, 0, 0, 0, GLFW_WINDOW);glewExperimental = GL_TRUE; glewInit(); // Try auto completing a function here (ex: glBindBuffer, or glGenBuffers)
}@
-
ClangCodeModel plugin marked as experimental and disabled by default. Open Help->"About Plugins", find C++/ClangCodeModel and enable it.
-
Just tried enabling it, and restarting QtCreator, it doesn't work. I tried restarting several times and have no better results :/ I actually tried using clang in vim to give me auto complete and it doesn't work. I made a thread about this on StackOverflow too and the only solution was either #define GL_GLEXT_PROTOTYPES, or use OpenGL Loader Generator and use OpenGL in a namespace, which gave me argument completion. But the code was this: gl::BindBuffer(arg1, arg2), etc, and there was some exceptions such as GL_TRUE which was gl::TRUE_.
However I dislike this solution because when somebody else comes by and sees my code, it won't be in the format of how they did it. I want to be able to use the C syntax of OpenGL somehow and get argument completion.
The SO threads are here:
http://stackoverflow.com/questions/15260891/vim-clang-complete-doesnt-see-some-functions-of-opengl
and
Is there really no other choice but to live with having to #define GL_GLEXT_PROTOTYPES or using OpenGL in a C++ namespace? Using Visual Studio is an option, but that would mean that I would have to install Windows and use it from there, and then I would have to install a vim plugin to emulate vim keybindings. (It's just that using windows and it not being compatible with linux is what's holding me back, since I want things to be cross-platform, etc. I'm using cmake to build and compile my projects, but I want to program in vim and in linux or at least just in linux)
-
There are no such bug report in clang tracker, so your can add new wish :)
http://llvm.org/bugs/buglist.cgi?quicksearch=completion&list_id=36022
Does Visual Studio really resolves this trick correctly? If it does, methion this fact in your wish. Btw, using GL_GLEXT_PROTOTYPES is quite good solution.
-
[quote author="sergey-shambir" date="1364668473"]There are no such bug report in clang tracker, so your can add new wish :)
http://llvm.org/bugs/buglist.cgi?quicksearch=completion&list_id=36022
Does Visual Studio really resolves this trick correctly? If it does, methion this fact in your wish. Btw, using GL_GLEXT_PROTOTYPES is quite good solution.[/quote]
I don't really know if Visual Studio does, but many people seem to claim that it does. Also, I heard that GL_GLEXT_PROTOTYPES is a bad option compared to using GLEW, since when I go cross-platform and compile, it might not even compile on Mac OSX. And then I would have to create my own function pointers, etc. Also, apparently it won't work for anything past 1.1.
I guess I could live with defining GL_GLEXT_PROTOTYPES. I just need more info on it before I can decide on using it though.
Thanks.
-
How about to include glew.h and then include gl.h with conditional GL_GLEXT_PROTOTYPES on linux?
-
[quote author="sergey-shambir" date="1364673430"]How about to include glew.h and then include gl.h with conditional GL_GLEXT_PROTOTYPES on linux?[/quote]
Just tried it this:
@#include <GL/glew.h>
#ifdef unix
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#endif@And it doesn't work, I still get no argument completion. However, if I do this:
@#ifdef unix
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#endif#include <GL/glew.h>@
Then I do get argument completion, but obviously, this gives me errors. When I compile, it says this:
/usr/include/GL/glew.h:84:2: error: #error gl.h included before glew.h
/usr/include/GL/glew.h:90:2: error: #error glext.h included before glew.h -
my current solution is:
@
#ifndef COUNTER//qt creator cannot parse this
#define GL_GLEXT_PROTOTYPES
#include <GL/glcorearb.h>//never compile this
#endif
@change the gl-file to your header in use, e. g. »gl.h«
-
I've used the solution from darklighter to create a little header file.
You can include it instead of glew.h to get argument completion together with glew in qtCreator.@//include glew.h (argument completion only in linux qtcreator)
#ifndef COUNTER
#ifdef unix
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glew.h>
#endif
#else
#include <GL/glew.h>
#endif@This works fine for me. :)