Re: [PyOpenGL-Users] glTexSubImage2D data format
Brought to you by:
mcfletch
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 |