Thread: [PyOpenGL-Users] Converted C++ project to python project (some issues)
Brought to you by:
mcfletch
From: Abhijeet R. <abh...@gm...> - 2011-04-17 22:36:39
|
Hi guyz, I need your help. After a day long process, I have finally completed a C++ pyopengl+glut project to python. Thanks for your help in making me move forward when I was stuck. Now, I have made to the code line by line same, all variable names same & even the order in which functions are written (even comments copied :P) but still the code is not executing perfectly. So the issue is about converting C++ to python successfully. Window0 ie left one doesnt load successfully, There is some problem of loading the windows.. DETAILS:- ^^^^^^^^^^ Screenshot of the issue:- http://i.imgur.com/qDax9.png C++ & python source code + images (SIZE 23KB) : http://dl.dropbox.com/u/7728421/paint.tar.gz C++ code (if you dont want to download): http://sprunge.us/JLOC?cpp Python source (if you dont want to download): http://sprunge.us/IVdG?python Error in console, ^^^^^^^^^^^^^^^ http://sprunge.us/gQRI I have tried my best to explain the issue. Its *probably a very small issue with textures variable acquiring None value but I am not able to solve the bug.* Please guyz help me making a working python clone of the code. I have to get this done till tomorrow somehow. Any kind of help would be greatly appreciated. -- Regards, Abhijeet Rastogi (shadyabhi) http://www.google.com/profiles/abhijeet.1989 |
From: Derakon <de...@gm...> - 2011-04-17 22:50:27
|
On Sun, Apr 17, 2011 at 3:36 PM, Abhijeet Rastogi <abh...@gm...> wrote: > I have tried my best to explain the issue. Its probably a very small issue > with textures variable acquiring None value but I am not able to solve the > bug. Have you tried printing the value of the textures variable after each time it's changed? That should quickly tell you where it's going wrong. -Chris |
From: Mike C. F. <mcf...@vr...> - 2011-04-17 23:12:23
|
On 11-04-17 06:50 PM, Derakon wrote: > On Sun, Apr 17, 2011 at 3:36 PM, Abhijeet Rastogi > <abh...@gm...> wrote: >> I have tried my best to explain the issue. Its probably a very small issue >> with textures variable acquiring None value but I am not able to solve the >> bug. > Have you tried printing the value of the textures variable after each > time it's changed? That should quickly tell you where it's going > wrong. > > -Chris Abhijeet, here's the changes I needed to make to get what I *think* is a working version of your code... mcfletch@sturm:~/OpenGL-dev/imagesnone$ diff -w main-orig.py main.py 177c177 < textures = glGenTextures(TEX_COUNT) --- > textures = None 318a319,321 > global textures > if not textures: > textures = glGenTextures(TEX_COUNT) 325d327 < global textures You are calling glGenTextures before you have a valid OpenGL context, this results in getting 4 values of 0 for the textures. Instead, only generate the texture ids the first time you need them. BTW, watch your indentation in Python, try to use either 4-space indents or if you feel very strongly about it, literal tab characters, mixing tabs and spaces is considered very bad form. The modified form does not produce any tracebacks on my machine (a Linux Ubuntu machine) until I hit one of the "buttons" in the palette. Don't have time to track down what that is, but it's likely a problem where the return type for select buffer is a custom object type in PyOpenGL. Good luck, Mike > ------------------------------------------------------------------------------ > Benefiting from Server Virtualization: Beyond Initial Workload > Consolidation -- Increasing the use of server virtualization is a top > priority.Virtualization can reduce costs, simplify management, and improve > application availability and disaster protection. Learn more about boosting > the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Abhijeet R. <abh...@gm...> - 2011-04-18 05:20:03
|
On Mon, Apr 18, 2011 at 4:41 AM, Mike C. Fletcher <mcf...@vr...>wrote: > > You are calling glGenTextures before you have a valid OpenGL context, > this results in getting 4 values of 0 for the textures. Instead, only > Instead of doing textures = glGenTextures(TEX_COUNT) in main, I did it in drawRAWs function global textures textures = glGenTextures(TEX_COUNT) Now, the textures are loaded perfectly but they are not selected and give some error. Googling ( http://pyopengl.sourceforge.net/documentation/opengl_diffs.html) told me that there are some differences the way selection buffers are handled. By the way, the error which I get is Traceback (most recent call last): File "_ctypes/callbacks.c", line 313, in 'calling callback function' File "main.py", line 651, in mouseWin2 selection(x, y, 2) File "main.py", line 299, in selection choiche = selectBuff[(hits*4)-1] TypeError: unsupported operand type(s) for -: 'list' and 'int' I know, I have used python datatype wrongly. I am figuring out how to do it. If I am not successful, I will ask the question on mailling list again. Thanks for your helo so far. -- Regards, Abhijeet Rastogi (shadyabhi) http://www.google.com/profiles/abhijeet.1989 |