python - OpenGL texture doesn't render -
python - OpenGL texture doesn't render -
the texture doesn't render, geometry black.
screenshot: http://i.imgur.com/ypmdqy4.png
code: http://pastebin.com/svb8rxxt
i'd link texture i'm trying render , transformations.py module, don't have reputation allowed set in more 2 links. googling "modern opengl 02" tutorial got former, , "transformations py" latter.
search "texture stuff start" find texture stuff set up.
i tried poking @ parts (image loading, texture loading, texture coordinate data, shaders) don't know of way determine @ fault, , seem fine far can tell.
update: updated code potential problems fixed, still exhibitng same issue.
i'm not python guy maybe i'm missing something.
having fragments rendering black has 1 of these things:
texture info isn't loaded texture isn't bound sampler shader something wrong lighting math uniforms aren't beingness sent correctly shader bad attributes normals (like if 0's).since shader straight finalcolor = texture(tex, fragtexcoord);
rules out lighting math , uniforms. has wrong texture sampler.
in ios when bind texture have following:
glactivetexture(gl_texture0); glbindtexture(gl_texture_2d, texture); gluniform1i(gluniforms[u_texturesampler], 0);
and assume need apply same steps. maybe texturebuffer.bind()
1 of more of steps you. otherwise somewhere need activating texture sampler, binding it, , setting uniform.
an non activated texture appear black. uniform isn't set right going homecoming 0 uniform.
somewhere have connect `uniform sampler2d tex' shader texture you're binding when rendering.
i think it's confusing , in bad form phone call texture id tex
(the 1 gets returned glgentextures
, phone call uniform `tex'. these 2 different things. 1 texture id, other uniform variable.
first thing i'd alter name of id tex
texid
maintain them straight in mind. might see no in code getting uniform location (glgetuniformlocation) of glsl uniform variable tex
, way has done after shader compiled. maybe there's helper there in python i'm not seeing.
but when texture buffer.bind
connecting things uniform variable 'tex'?
* update 1 *
a suggestion on how uniform location , utilize it. after shader compiled. passes uniform location id app:
u_tex = glgetuniformlocation(shader, "tex")
change texture id variable texid
this:
texid = glgentextures(1) glbindtexture(gl_texture_2d, texid)
then in display loop when bind texture utilize do:
glactivetexture(gl_texture0) glbindtexture(gl_texture_2d, texid) gluniform1i(u_tex, 0)
and have admit don't know texturebuffer.bind()
does. seek 3 lines above either before or after line.
* update 2 *
just noticed you're missing glenable(gl_texture_2d)
should right there along gltexparameter stuff. add together above lines.
* update 3 *
just test in shader replace finalcolor = texture(tex, fragtexcoord);
finalcolor = vec4(1.0,0.0,0.0,1.0);
, see if box turns red. cause think of don't know finalcolor
is. should gl_fragcolor =
.
* update 4 *
do above test , create sure can set color of fragment manually. didn't realize in opengl 3.0. thinking 2.0. output variable name depends on glsl version. you've set version 1.3. see post , create sure you're doing part right also: how fragment shader know variable utilize color of pixel?
python opengl texturing
Comments
Post a Comment