opengl - Contents of uniform int[8] area always zero? -
i'm building shader program render simple bitmap font in glsl.
my programming environment c# i'm using opentk encapsulate opengl 4.0, syntax similar examples in c , c++.
my issue i'm trying pass array of integers fragment shader, whenever do, array elements end being zero. integers should range between 0 , 255 , i've checked values before , after sending them. it's infuriating.
currently i'm binding program, attempting send int[] array shader using following instructions:
int[] ints = new int[] { 33, 34, 35, 36, 37, 38, 39, 40 }; gl.useprogram(programlocation); gl.uniform1(arraylocation, ints.length, ints);
my fragment shader takes array , uses couple of functions determine part of quad place characters. i've tested these functions static numbers , arrays build manually in shader , work i'd expect them to. reason syntax above doesn't end sending data - elements evaluate 0.
in shader, array denoted , used this:
uniform int characters[8]; .... gl_fragcolor = texture2d(bitmapfonttex, getbitmapfontstart(characters[0...8etc]));
the rest of code seems work when tested in isolation - falls apart when comes together, , above code blocks comes together. have made silly rookie mistake, or there more screwy happening? appreciated.
you using wrong version of gluniform*()
want use sending 1d array of ints gluniform1iv()
.
note how i
int, f
float. number represents number of elements. arrays suffix v
, number represents dimensions.
gl.uniform1iv(arraylocation, ints.length, ints);
here link reference https://www.opengl.org/sdk/docs/man/docbook4/xhtml/gluniform.xml
Comments
Post a Comment