Ha!   the access error was caused by specifying RGBA when the image was 
actually RGB.

On Monday, May 25, 2020 at 11:14:10 AM UTC+1, Nicky Mac wrote:
>
>
> I don't  have a problem creating and applying square textures, using 
> windows10 python36 and latest pyglet
> but following  tutorials to apply 'tarnish' size 512 x 256 I get an access 
> violation.
> Here is th stripped-down code:
> #!/usr/bin/env python
> import pyglet
> from pyglet.gl
>  import *
> from pyglet import window, image, resource
> from pyglet.window import key
> from random   import randint
> from math     import cos, sin
> from glframe  import GLFrame
> from fakeglut import glutSolidSphere
> from gltools  import gltDrawSphere
> from math3d   import M3DMatrix44f, m3dInvertMatrix44
>
> frameCamera = GLFrame()
>
> class MainWindow(window.Window):
>     def __init__(self, *args, **kwargs):
>         window.Window.__init__(self, *args, **kwargs)
>         # Cull backs of polygons
>         glCullFace(GL_BACK)
>         glFrontFace(GL_CCW)
>         glEnable(GL_CULL_FACE)
>         glEnable(GL_DEPTH_TEST)
>
>         # get tarnish texture object as texture unit 0
>         glActiveTexture(GL_TEXTURE0)
>         glEnable(GL_TEXTURE_2D)
>         img = image.load('Assets/tarnish.jpg')
>         print('set tarnish 
> texture',(img.width,img.height),img.pitch,type(img))
>         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width, img.height, 0, 
> GL_RGBA,
>                          GL_UNSIGNED_BYTE, img.get_data('RGBA', img.pitch))
>         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
>         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, 
> GL_LINEAR_MIPMAP_LINEAR);
>         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 
> GL_CLAMP_TO_EDGE);
>         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 
> GL_CLAMP_TO_EDGE)        
>         glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE)        
>         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
>
> which produces:
> set tarnish texture (512, 256) -1536 <class 'pyglet.image.ImageData'>
> Traceback (most recent call last):
>   File "C:\Python\Python36\Dhruve and me\Pyglet\github_tarnish.py", line 
> 105, in <module>
>     w = MainWindow(800, 600, caption='OpenGL Cube Maps Camera:Arrow keys', 
> resizable=True)
>   File "C:\Python\Python36\Dhruve and me\Pyglet\github_tarnish.py", line 
> 30, in __init__
>     GL_UNSIGNED_BYTE, img.get_data('RGBA', img.pitch))
> OSError: exception: access violation reading 0x00000234EA147000
> >>>.
>
> <https://drive.google.com/u/0/settings/storage?hl=en-GB&utm_medium=web&utm_source=gmail&utm_campaign=manage_storage>
> <https://www.google.com/intl/en-GB/policies/terms/> 
> <https://www.google.com/intl/en-GB/policies/privacy/> 
> <https://www.google.com/gmail/about/policy/>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyglet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyglet-users/58b6584c-f70b-49fd-b0b6-05ab32cc7528%40googlegroups.com.

Reply via email to