Thread: [PyOpenGL-Users] glTexSubImage2D data format
Brought to you by:
mcfletch
From: Mohan G. <mg...@ca...> - 2009-11-10 17:07:41
|
Hi, I'm trying to port some very elementary GPGPU code (based on http://www.mathematik.uni-dortmund.de/~goeddeke/gpgpu/tutorial.html) to run with Python(+PyOpenGL+pygame). I'm running into some difficulties translating the following line... glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, GL_LUMINANCE, GL_FLOAT, data) I think the problem is that I don't have 'data' in the right format. (I've tried several things, including arrays and strings. In the original C code it's just a float*.) Would anyone be able to tell me what the appropriate format in Python would be? Thank you in advance, Mohan |
From: Gijs <in...@bs...> - 2009-11-10 17:41:50
|
On 10-11-2009 18:07, Mohan Ganesalingam wrote: > Hi, > > I'm trying to port some very elementary GPGPU code (based on > http://www.mathematik.uni-dortmund.de/~goeddeke/gpgpu/tutorial.html) to run > with Python(+PyOpenGL+pygame). I'm running into some difficulties > translating the following line... > > glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, > GL_LUMINANCE, GL_FLOAT, data) > > I think the problem is that I don't have 'data' in the right format. (I've > tried several things, including arrays and strings. In the original C code > it's just a float*.) Would anyone be able to tell me what the appropriate > format in Python would be? > > Thank you in advance, > Mohan > Hi Mohan, I usually use Numpy arrays for calls like this. So something like this: data = zeros(width*height, 'f')+0.5 glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, GL_LUMINANCE, GL_FLOAT, data) This should give all your texels a value of 0.5. Regards, Gijs |
From: Mohan G. <mg...@ca...> - 2009-11-10 18:16:13
|
Hi Gijs, >I usually use Numpy arrays for calls like this. So something like this: >data = zeros(width*height, 'f')+0.5 >glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, >GL_LUMINANCE, GL_FLOAT, data) Thanks for the suggestion! Unfortunately I'm still getting an error... I'm sure I'm doing something stupid, but would you mind taking a look at it? (I can post the complete source code as well, but it's >100 lines, so I'm not sure whether it's all right to send it to the list... ) thanks again, Mohan Error: Traceback (most recent call last): File "C:\Mohan\pygpu\test.py", line 110, in <module> glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, GL_LUMINAN CE, GL_FLOAT, data) File "C:\Program Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 1284, in __call__ return self.finalise()( *args, **named ) File "C:\Program Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 681, in wrapperCall raise err OpenGL.error.GLError: GLError( err = 1281, description = 'invalid value', baseOperation = glTexSubImage2D, pyArgs = ( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 512, 512, GL_LUMINANCE, GL_FLOAT, array([ 0.30000001, 0.30000001, 0.3..., ), cArgs = ( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 512, 512, GL_LUMINANCE, GL_FLOAT, array([ 0.30000001, 0.30000001, 0.3..., ), cArguments = ( GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, 512, 512, GL_LUMINANCE, GL_FLOAT, c_void_p(90243104), ) ) |
From: Gijs <in...@bs...> - 2009-11-10 19:52:01
|
On 11/10/09 19:15 , Mohan Ganesalingam wrote: > Hi Gijs, > > >> I usually use Numpy arrays for calls like this. So something like this: >> data = zeros(width*height, 'f')+0.5 >> glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, >> GL_LUMINANCE, GL_FLOAT, data) >> > Thanks for the suggestion! Unfortunately I'm still getting an error... I'm > sure I'm doing something stupid, but would you mind taking a look at it? (I > can post the complete source code as well, but it's>100 lines, so I'm not > sure whether it's all right to send it to the list... ) > > thanks again, > Mohan > > Error: > > Traceback (most recent call last): > File "C:\Mohan\pygpu\test.py", line 110, in<module> > glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, > GL_LUMINAN CE, GL_FLOAT, data) > File "C:\Program > Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 1284, in > __call__ > return self.finalise()( *args, **named ) > File "C:\Program > Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 681, in > wrapperCall > raise err > OpenGL.error.GLError: GLError( > err = 1281, > description = 'invalid value', > baseOperation = glTexSubImage2D, > pyArgs = ( > GL_TEXTURE_RECTANGLE_ARB, > 0, > 0, > 0, > 512, > 512, > GL_LUMINANCE, > GL_FLOAT, > array([ 0.30000001, 0.30000001, 0.3..., > ), > cArgs = ( > GL_TEXTURE_RECTANGLE_ARB, > 0, > 0, > 0, > 512, > 512, > GL_LUMINANCE, > GL_FLOAT, > array([ 0.30000001, 0.30000001, 0.3..., > ), > cArguments = ( > GL_TEXTURE_RECTANGLE_ARB, > 0, > 0, > 0, > 512, > 512, > GL_LUMINANCE, > GL_FLOAT, > c_void_p(90243104), > ) > ) > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > After reviewing your code it appeared that you didn't first set the texture format/width/height/etc, using glTexImage2D. You first have to define this before you do something with it, for instance call glTexSubImage2D on it. This can be done using the following code: glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_FLOAT, zeros(width*height, 'f')) Regards, Gijs |
From: Mohan G. <mg...@ca...> - 2009-11-10 20:24:39
|
Dear Gijs, thank you so much! Mohan >Hi Gijs, > >>I usually use Numpy arrays for calls like this. So something like this: >>data = zeros(width*height, 'f')+0.5 >>glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, >>GL_LUMINANCE, GL_FLOAT, data) > > Thanks for the suggestion! Unfortunately I'm still getting an error... > I'm sure I'm doing something stupid, but would you mind taking a look at > it? (I can post the complete source code as well, but it's >100 lines, so > I'm not sure whether it's all right to send it to the list... ) > >thanks again, >Mohan > >Error: > >Traceback (most recent call last): > File "C:\Mohan\pygpu\test.py", line 110, in <module> > glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, >GL_LUMINAN CE, GL_FLOAT, data) > File "C:\Program >Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 1284, in >__call__ > return self.finalise()( *args, **named ) > File "C:\Program >Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 681, in >wrapperCall > raise err >OpenGL.error.GLError: GLError( > err = 1281, > description = 'invalid value', > baseOperation = glTexSubImage2D, > pyArgs = ( > GL_TEXTURE_RECTANGLE_ARB, > 0, > 0, > 0, > 512, > 512, > GL_LUMINANCE, > GL_FLOAT, > array([ 0.30000001, 0.30000001, 0.3..., > ), > cArgs = ( > GL_TEXTURE_RECTANGLE_ARB, > 0, > 0, > 0, > 512, > 512, > GL_LUMINANCE, > GL_FLOAT, > array([ 0.30000001, 0.30000001, 0.3..., > ), > cArguments = ( > GL_TEXTURE_RECTANGLE_ARB, > 0, > 0, > 0, > 512, > 512, > GL_LUMINANCE, > GL_FLOAT, > c_void_p(90243104), > ) >) > > |
From: Gijs <in...@bs...> - 2009-11-10 20:57:44
|
No problem :) On 10-11-2009 21:24, Mohan Ganesalingam wrote: > Dear Gijs, > > thank you so much! > > Mohan > > >> Hi Gijs, >> >> >>> I usually use Numpy arrays for calls like this. So something like this: >>> data = zeros(width*height, 'f')+0.5 >>> glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, >>> GL_LUMINANCE, GL_FLOAT, data) >>> >> Thanks for the suggestion! Unfortunately I'm still getting an error... >> I'm sure I'm doing something stupid, but would you mind taking a look at >> it? (I can post the complete source code as well, but it's>100 lines, so >> I'm not sure whether it's all right to send it to the list... ) >> >> thanks again, >> Mohan >> >> Error: >> >> Traceback (most recent call last): >> File "C:\Mohan\pygpu\test.py", line 110, in<module> >> glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, >> GL_LUMINAN CE, GL_FLOAT, data) >> File "C:\Program >> Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 1284, in >> __call__ >> return self.finalise()( *args, **named ) >> File "C:\Program >> Files\_Coding\Python26\lib\site-packages\OpenGL\wrapper.py", line 681, in >> wrapperCall >> raise err >> OpenGL.error.GLError: GLError( >> err = 1281, >> description = 'invalid value', >> baseOperation = glTexSubImage2D, >> pyArgs = ( >> GL_TEXTURE_RECTANGLE_ARB, >> 0, >> 0, >> 0, >> 512, >> 512, >> GL_LUMINANCE, >> GL_FLOAT, >> array([ 0.30000001, 0.30000001, 0.3..., >> ), >> cArgs = ( >> GL_TEXTURE_RECTANGLE_ARB, >> 0, >> 0, >> 0, >> 512, >> 512, >> GL_LUMINANCE, >> GL_FLOAT, >> array([ 0.30000001, 0.30000001, 0.3..., >> ), >> cArguments = ( >> GL_TEXTURE_RECTANGLE_ARB, >> 0, >> 0, >> 0, >> 512, >> 512, >> GL_LUMINANCE, >> GL_FLOAT, >> c_void_p(90243104), >> ) >> ) >> >> >> > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > |