glGenRenderbuffersEXT not declared but glGenFramebuffersEXT works - qt

I am trying to use RBOs in a project which uses QGLWidget. Now, when I want to use RBOs for a fast read of a texture the compiler says 'glGenRenderbuffersEXT' was not declared in this scope. The same with FBO (glGenFramebuffersEXT) works fine.
The gl relevant includes I use:
#include <GL/glew.h>
#include <QtOpenGL>
I link against the glew library, too.
Here a dump of my CMakeLists.txt:
include_directories(
${GLEW_INCLUDE_PATH}
${PROJECT_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS}
${CG_INCLUDE_PATH}
)
set(LIBS
${GLEW_LIBRARY}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
${CG_LIBRARY}
${CG_GL_LIBRARY}
${OpenCV_LIBS}
${GFlags_LIBS}
${QT_LIBRARIES}
common
ndiolib
optimization-static
LightingLib-static
)
SOURCE_GROUP("Shader Files" FILES ${SHADER_FILES})
add_executable(Relighting ${HDRS} ${SRCS} ${MOCSRC} ${SHADER_FILES} main.cxx)
target_link_libraries(Project ${LIBS})
Anybody has an idea, what could be wrong? When I tried to use glext.h (+gl.h) instead of glew.h, both the RBOs and the FBOs weren't found.
Side-question: Should I use RBOs for reading out a texture at all? Or is it equally fast to use the FBO which I use to read out the texture?

I check OpenGL site and it seems that the function you mentioned is defined only if you have GL_GLEXT_PROTOTYPES defined.
http://www.opengl.org/registry/api/glext.h
Further digging shows that you do need to define this symbol in order to use prototypes of extensions.
http://www.opengl.org/registry/ABI/#5

Related

CMake COMPILE_DEFINITIONS triggering incorrect number of arguments

I'm having problem understanding how to correctly set the COMPILE_DEFINITIONS target properti in CMake.
my target is add_library(modelutilities STATIC ${modelutilities_SRCS})
I if use
set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
set_target_properties(modelutilities PROPERTIES
VERSION "0.0.1"
SOVERSION 0
EXPORT_NAME "ModelUtilities"
ARCHIVE_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/bin"
COMPILE_DEFINITIONS ${modelutilities_COMPILE_DEFINE}
)
everything works fine, but if I add another line between them with set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} MODELUTILITIES_LIB) it stops working complaining that set_target_properties was called with the wrong number of arguments.
Anyone can spot what I'm doing wrong?
P.S.
I already tried using doublequotes: set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} "MODELUTILITIES_LIB"). It did not change anything
P.P.S.
If I message(STATUS ${modelutilities_COMPILE_DEFINE}) QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB in the first case and QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;MODELUTILITIES_LIB in the second
With newer version of CMake, what is being preached is the idea of targets. So, for example, instead of include_directories() it's now preferred to use target_include_directories().
That being the case I think you'd be better served using the preferred target_compile_definitions() to set compile definitions for your utilities library.
One advantage you get is that your can scope your compile definitions using the PUBLIC or PRIVATE keywords.

Compiling QtOpenCL with QT5

Anyone managed to compile library QtOpenCL using Qt5 (possibly under Window)?
edit: I managed to compile the code by porting it to QT5. I leave here in the question the dirty parts that I would like to replace in my method and describe what I did in the answer.
I was not able to provide the include path to my opencl installation so I
manually modified src/opencl/opencl.pro by adding the line
INCLUDEPATH += " *[absolute path to the openCL include folder]* "
QMAKE_LIBDIR_OPENCL = "*[absolute path to the opencl lib folder]*"
manually modified src/openclgl/openclgl.pro by adding the line
INCPATH += " *[absolute path to the openCL include folder]* "
QMAKE_LIBDIR_OPENCL = "*[absolute path to the opencl lib folder]*"
Anyone knows how to fix this in a cleaner way?
Here are the changes I had to introduce:
Modify the .pro files in order to add the OpenCL library. This is still an open problem for me. How to fix this in a cleaner way?
Link the projects (both opencl.pro and openclgl.pro) to the additional required Qt module QtConcurrent:
QT += concurrent
Fix the #include style by removing the packages, e.g. #include <qtconcurrentrun.h> instead of the old #include
<QtCore/qtconcurrentrun.h>
Fix qclvector.cpp by replacing qMalloc, qfree, qMemCopy with, respectively, std::malloc, std::free, std::memcpy
Moreover modify the initialization of ref in the constructor from ref = 1 to ref.store(1);
Removing all the macros QT_LICENSED_MODULE
This is enough to compile at least QtOpenCL and QtOpenCLGL using QT5

What API does Qt use for interacting with the Windows clipboard?

I've been browsing the Qt source code trying to find the actual system calls but it seems Qt doesn't use the Windows API documented on MSDN. For example grepping the source for "GetClipboardData" returns results in two files:
qclipboard_win.cpp:
#if defined(Q_OS_WINCE)
...
HANDLE clipData = GetClipboardData(CF_TEXT)
qaxserverbase.cpp:
STDMETHOD(GetClipboardData)(DWORD dwReserved, IDataObject** ppDataObject);
...
HRESULT WINAPI QAxServerBase::GetClipboardData(DWORD, IDataObject**)
{
return E_NOTIMPL;
}
and "SetClipboardData":
qclipboard_win.cpp:
#if defined(Q_OS_WINCE)
...
result = SetClipboardData(CF_UNICODETEXT, wcsdup(reinterpret_cast<const wchar_t *> (data->text().utf16()))) != NULL;
Neither of which seems useful, since they're being declared for Win CE/Mobile.
My Qt (4.8.1) uses OleSetClipboard and OleGetClipboard. The lines you got to are never reached in regular windows, as only in case of #if defined(Q_OS_WINCE) Qt uses #define OleSetClipboard QtCeSetClipboard and #define OleGetClipboard QtCeGetClipboard, and otherwise uses system-provided versions of those functions.
It was a little dificult to see this #if defined though, so you are excused ;)
It is so at least on my Qt version. If you are talking about qt, and especially about it's internals, you should menstion the version, right?

Qt program does not link, no moc file generated

I'm using Qt, CMake, and the VS2010 compiler. There seems to be a problem when I'm linking a small piece of test code. The linkers gives the following error:
plotter.cpp.obj : error LNK2001: unresolved external symbol "public: virtual str
uct QMetaObject const * __thiscall Plotter::metaObject(void)const " (?metaObject
#Plotter##UBEPBUQMetaObject##XZ)...
(it goes on for a while)
The error occurs when I'm trying to inherit from QObject in the following code:
class Plotter : public QObject
{
Q_OBJECT
public:
If I leave out the Q_OBJECT, the program links, but I can't use the class slots at runtime.
I noticed that no moc file is generated for plotter.h. This is my CMakeLists.txt:
cmake_minimum_required (VERSION 2.6)
project (ms)
SET(CMAKE_BUILD_TYPE "Release")
FIND_PACKAGE(Qt4)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
LINK_LIBRARIES(
${QT_LIBRARIES}
)
set(all_SOURCES plotter.cpp main.cpp dialog.cpp)
QT4_AUTOMOC(${all_SOURCES})
add_executable(ms ${all_SOURCES})
target_link_libraries(ms ${LINK_LIBRARIES})
A moc file is generated for dialog.cpp, but not for plotter.cpp, how is this possible?
Thanks!
First of all, ensure you are using QT4_AUTOMOC correctly. As the documentation points out, you still need to properly include the mocced files in your sources.
Also notice that QT4_AUTOMOC is still marked as experimental by CMake, so be sure it actually does what you expect and correctly generates the required files. If not, consider switching to the more robust classic solution using QT4_WRAP_CPP:
# notice that you need to pass the *header* here, not the source file
QT4_WRAP_CPP(MY_MOCED_FILES plotter.hpp)
# optional: hide the moced files in their own source group
# this is only useful if using an ide that supports it
SOURCE_GROUP(moc FILES ${MY_MOCED_FILES})
# then include the moced files into the build
add_executable(ms ${all_SOURCES} ${MY_MOCED_FILES})
Apart from that, your CMake file seems fine.

Getting values from pro files in Qt

I am using Qt 4.5 in Windows XP. My pro file has the variable VERSION = 1.0. Now i need to read this variable and get its value (1.0) from the source code. So that I don't have to maintain another variable for version inside my source code. I just read from the pro file and update it. So that the value remains consistent all over my project. Is it possible? Any pointers regarding this are welcome..
Use somethings like this:
DEFINES += VERSION=\\\"$$VERSION\\\"
This will define a macro that you can use in C source code. Get rid of the backslashes and quotes if you want a number, not a string.
I'll elaborate on this a bit.
In the YourApp.pro:
VERSION = 0.0.0.1
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
In the main.cpp:
#include <QApplication>
QCoreApplication::setApplicationVersion(QString(APP_VERSION));
Wherever else in your sources, e.g. in the imaginary controller.cpp:
#include <QApplication>
QString yourAppVersion = QCoreApplication::applicationVersion();
somehow, when I tried qDebug() << QString(APP_VERSION); in a class.cpp not in main.cpp. has an error "C2065" APP_VERSION: undeclared identifier". but when I tried in main.cpp that worked.

Resources