glBindTexture - returns argument error - python-2.7

I am working on augmented reality project. So the user should use the Webcam, and to see the captured video with a cube drawn on that frame.
And this is where I get stuck , when I try to use glBindTexture(GL_TEXTURE_2D,texture_background) method, I get error:
(
ArgumentError: argument 2: : wrong type
GLUT Display callback with (),{} failed: returning None argument 2: : wrong type
)
I am completely stuck, have no idea what to do . The project is done in Python 2.7 , am using opencv and PyOpenGl 3.1.0.
You can find code on this link :click here
Thanks in advance.

Interesting error! So I played around with your source code (by the way in the future you should probably just add the code directly to your question instead of as a separate link), and the issue is actually just one of variable scope, not glut or opengl usage. The problem is your texture_background variable does not exist within the scope of the _draw_scene() function. To verify this, simply try calling print texture_background in your _draw_scene() function and you will find it returns None rather than the desired integer texture identifier.
The simple hack-y solution is to just call global texture_background before using it within your _handle_input() function. You will also need to define texture_background = None in the main scope of your program (underneath your ##FOR CUBE FROM OPENGL comment). The same global comment applies for x_axis and z_axis.
That being said, that solution is not really that great. The rigid structure required by GLUT with all of these predefined glut* functions makes it hard to structure code the way you might want to in terms of initializing your app. I would suggest, if you are not forced to use GLUT, to use a more flexible alternative, such as pygame, pysdl2 or pyqt, to create your context instead.

Related

wglCreateContextAttribsARB not defined?

C++ application, I define a temp context, make it current, and then try to use wglCreateContextAttribsARB, which is simply undefined. Most answers I have seen say to use PFNWGLCREATECONTEXTATTRIBSARBPROC. Which is also undefined. What am I missing?
I'm only using gl.h (provided by VS2015)
SetPixelFormat(g_hDc, chosenPixelFormat, &pfd);
HGLRC temporaryContext = wglCreateContext(g_hDc);
wglMakeCurrent(g_hDc, temporaryContext);
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB...
Both, however, are just unidentified. I initially tried calling wglCreateContextAttribsARB by itself, to no avail, anywhere in my code.
At this stage, I have a context working, windowed, 480p, updating, stable 60FPS. So I know my side is working. I'm getting no GL errors either. Where do I need to instantiate these two? Am I using the wrong gl header?
I'm using an updated ASUS Radeon R9-285
All data types and constants related to wgl extensions are declared in wglext.h.
You need to query the function pointer of type PFNWGLCREATECONTEXTATTRIBSARBPROC using your current context via the GL extension mechansim (e.g. wglGetProcAddress()).

Gtk::ScaleButton: Icons in the constructor

I am trying to use a Gtk::ScaleButton in Gtkmm 3. My problem is the constructor. It needs as last parameter (see here: https://developer.gnome.org/gtkmm/stable/classGtk_1_1ScaleButton.html#a96753b6cb6b8adb0ed3727ba3eb8cfb7 ) a vector of ustrings. I guess (i can't find it in the docs what it means exactly) i have to give it the path to the +/- Images. I want to use the Gtk Stock items for +/-. How can i achieve this?
Currently i give it an empty vector, which results in a glibmm warning:
std::vector<Glib::ustring> icons;
Gtk::ScaleButton * scale = Gtk::manage(new Gtk::ScaleButton(Gtk::ICON_SIZE_SMALL_TOOLBAR, 0.0, 10.0, 1.0, icons));
Warning:
glibmm-WARNING **: Glib::ConstructParams::ConstructParams(): object class "gtkmm__GtkScaleButton" has no property named "min"
How can i avoid the warning and give it stock icons?
You must be one of the first people to ever try using this Gtk::ScaleButton constructor from gtkmm. It seems to have been broken for several years.
I've fixed it in gtkmm: https://git.gnome.org/browse/gtkmm/commit/?id=26f94d231da9481d74acdd94e56168ed6b38609a
But it will be some time until that is widely available via Linux distro packages. In the meantime you can try using
Gtk::ScaleButton* button = Glib::wrap(gtk_scale_button_new(whatever));
See https://developer.gnome.org/gtkmm-tutorial/stable/sec-basics-gobj-and-wrap.html.en
However, I don't know how it's actually meant to behave, so you might encounter other bugs. You might actually want to use the derived Gtk::VolumeButton instead.
andlabs is correct that the GTK+ documentation describes the icons better:
https://developer.gnome.org/gtk3/stable/GtkScaleButton.html#GtkScaleButton--icons
and those should indeed probably be the standard icon names:
http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html

Migrating to vtk6: Is it not necessary to Update() (anymore)?

Migrating some code from VTK 5.10 to 6.1, I have several code pieces like this:
vtkSmartPointer<vtkImageData> img = vtkSmartPointer<vtkImageData>::New();
// ... initialize img somehow, e.g. copy from other image:
img->DeepCopy(otherImg);
img->SetInformation(otherImg->getInformation());
// the problematical statement:
img->Update();
At the call to Update(), the compiler now complains that there isn't such a function (anymore).
The migration site from VTK doesn't really tell me too much about that - I believe this falls into the section Removal of Data Objects’ Dependency on the Pipeline , but as it's no Algorithm which is filling my image, I can't call update on an algorithm.
Similar goes for custom-filled vtkPolyData objects.
My question now is: Is the call to Update not necessary (anymore?), can I just remove it? Or by what would I need to replace it?
I have to say I'm relatively new to vtk, so if there's something fundamentally simple that I'm missing I'd be glad if you could point it out to me!
I think you've been meaning to call Modified() on your image rather than Update().
Apparently they already answered your question on VTK:
http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Removal_of_Update

OpenGL Multitexturing - glActiveTexture is NULL

I have started a new project, which I want to use multitexturing in.
I have done multixexturing before, and is supported by my version of OpenGL
In the header I have:
GLuint m_TerrainTexture[3];//heightmap, texture map and detail map
GLuint m_SkyboxTexture[5]; //left, front, right, back and top textures
PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
PFNGLACTIVETEXTUREARBPROC glActiveTexture;
In the constructor I have:
glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB");
glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress((LPCSTR)"glMultiTexCoord2fARB");
if(!glActiveTexture || !glMultiTexCoord2fARB)
{
MessageBox(NULL, "multitexturing failed", "OGL_D3D Error", MB_OK);
}
glActiveTexture( GL_TEXTURE0_ARB );
...
This shows the message box "multitexturing failed" and the contents of glActiveTexture is 0x00000000
when it gets to glActiveTexture( GL_TEXTURE0_ARB ); I get an access violation error
I am implementing the MVC diagram, so this is all in my terrain view class
You quoted your code to load the extensions like following:
PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
PFNGLACTIVETEXTUREARBPROC glActiveTexture;
glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB");
glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress((LPCSTR)"glMultiTexCoord2fARB");
This is very problematic, since it possibly redefines already existing symbols. The (dynamic) linker will eventually trip over this. For example it might happen that the assignment to the pointer variable glActiveTexture goes into some place, but whenever a function of the same name is called it calls something linked in from somewhere else.
In C you usually use a combination of preprocessor macros and custom prefix to avoid this problem, without having to adjust large portions of code.
PFNGLMULTITEXCOORD2FARBPROC myglMultiTexCoord2fARB;
#define glMultiTexCoord2fARB myglMultiTexCoord2fARB
PFNGLACTIVETEXTUREARBPROC myglActiveTexture;
#define glActiveTexture myglActiveTexture
glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB");
glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress((LPCSTR)"glMultiTexCoord2fARB");
I really don't know of any other reason why things should fail if you have a valid render context active and the extensions supported.
GLEE is a dead library; it hasn't been updated in a long time.
GLEW is a fine extension loading library, but it has some issues working with core 3.2 and above.
I would suggest GL3W. The beauty of it is that it is self-updating; it downloads and parses the headers by itself. The downside is that you need a Python 2.6 installation to generate the loader. But it provides reasonably good results otherwise.
I recommend GLEW/GLEE for extension management.
Rastertek tutorial has the complete setup required to make wglGetProcAddress to work. GLEW doesn't work for me either, I've tried everything I could think of and I asked many people about it but it simply doesn't work in VS 2012, not to mention the enormous frustration I experienced when I wanted to compile a shader.

What has to be Glib::init()'ed in order to use Glib::wrap?

So I'm trying to make use of a GtkSourceView in C++ using GtkSourceViewmm, whose documentation and level of support give me the impression that it hasn't been very carefully looked at in a long time. But I'm always an optimist :)
I'm trying to add a SourceView using some code similar to the following:
Glib::RefPtr<gtksourceview::SourceLanguageManager> source_language_manager = gtksourceview::SourceLanguageManager::create();
Glib::RefPtr<gtksourceview::SourceLanguage> source_language = Glib::wrap(gtk_source_language_manager_guess_language(source_language_manager->gobj(), file, NULL));
Glib::RefPtr<gtksourceview::SourceBuffer> source_buffer = gtksourceview::SourceBuffer::create(source_language);
gtksourceview::SourceView* = m_source_view = new gtksourceview::SourceView(source_buffer);
m_vbox.pack_start(*m_source_view);
Unfortunately, it spits out the warning
(algoviz:4992): glibmm-WARNING **:
Failed to wrap object of type
'GtkSourceLanguage'. Hint: this error
is commonly caused by failing to call
a library init() function.
and when I look at it in a debugger, indeed the second line above (the one with the Glib::wrap()) is returning NULL. I have no idea why this is, but I tried to heed the warning by adding Glib::init() to the begining of the program, but that didn't seem to help at all either.
I've tried Google'ing around, but have been unsuccessful. Does anyone know what Glib wants me to init in order to be able to make that wrap call? Or, even better, does anyone know of any working sample code that uses GtkSourceViewmm (not just regular GtkSourceView)? I haven't been able to find any actual sample code, not even on Google Code Search.
Thanks!
It turns out, perhaps not surprisingly, that what I needed to init was:
gtksourceview::init();
After this, I ran into another problem with one of the parameter to gtksourceview::SourceLanguageManager, but this was caused by a genuine bug which I subsequently reported and was promptly fixed. So everything's working great now!
I use gtkmm. Typically you have to initialize things with something like :
_GTKMain = new Gtk::Main(0, 0, false);
Of course do not forget :
delete _GTKMain;
Check here for details :
http://library.gnome.org/devel/gtkmm/2.19/classGtk_1_1Main.html
(Sorry but the link option does not work ...)