c# - OpenGL texture+lightning+blending trouble -


i'm using opentk , there difficulty me understand concept of opengl enabling functions. perspective matrix in onresize function.

i trying show texture.

my render function:

        gl.clearcolor(0.5f, 0.5f, 0.5f, 1.0f);          gl.clear(clearbuffermask.colorbufferbit | clearbuffermask.depthbufferbit);         gl.matrixmode(matrixmode.modelview);         gl.loadidentity();         gl.enable(enablecap.texture2d);         gl.enable(enablecap.depthtest);         ground.draw(); 

my ground.draw() function(sizexz.z, sizexz.y constants):

        gl.pushmatrix();         gl.translate(new vector3(-sizexz.x / 2, -1, sizexz.y / 2));         gl.bindtexture(texturetarget.texture2d, textures.gettextureid(texturename));         gl.begin(primitivetype.quads);         gl.color3(1,1,1);         gl.normal3(0, 1, 0);         gl.texcoord2(1f, 1f); gl.vertex3(0, 0, 0);         gl.texcoord2(1f, 0f); gl.vertex3(sizexz.x, 0, 0);         gl.texcoord2(0f, 0f); gl.vertex3(sizexz.x, 0, -sizexz.y);         gl.texcoord2(0f, 1f); gl.vertex3(0, 0, -sizexz.y);         gl.end();         gl.popmatrix(); 

it shows black non-textured quad. when add light texture appears, disappears color of quads:

gl.bindtexture(texturetarget.texture2d, textures.gettextureid(texturename)); gl.begin(primitivetype.quads); gl.normal3(0, 0, 1); if (true) gl.color4(0,1,0,1); // appears background color, not green if (false) gl.texcoord2(1f, 0f); gl.vertex3(0, 0, 0); if (false) gl.texcoord2(1f, 1f); gl.vertex3(3f, 0, 0); if (false) gl.texcoord2(0f, 1f); gl.vertex3(3f, 3f, 0); if (false) gl.texcoord2(0f, 0f); gl.vertex3(0, 3f, 0); gl.color4(1, 1, 1, 1); gl.end(); 

there 2 problems in program:

1. usage of color3

looking @ opentk color3 documentation, notice there 2 overloads of function:

color3  (double red, double green, double blue) color3  (sbyte red, sbyte green, sbyte blue) 

the reason why gl.color3(1,1,1) gives black object is, uses sbyte version values assumed in range [0, 255]. 1 dark. note gl.color3(1.0,1.0,1.0) calls double overload.

2. gl_texture_env_mode

by default set gl_modulate multiplies texture color vertex color. 1., makes texture disappear. more details on given here


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -