Hi! Evan's makeCheckImage function creates a new array and passes it to the caller as a return value. You need to store it in the variable that is passed to glTexImage2D; right now you are indeed giving it an empty (uninitialized) texture array. Change the call to:
checkImage = makeCheckImage() /simon Den 4 jul 2013 03.07, "Thomas F Steinhauer" <tom_steinha...@hotmail.com> skrev: Dear Evan, I tried the code that you have listed, It worked but no texture showed up on the quads. They were empty. I have pasted the whole code here as I have it now in hopes that someone might be able to figure out what is going on or maybe if I did something wrong. > /* > * Texture: CheckerBoard-pattern texture > */ > > const int checkImageWidth = 64; // Texture image rows and columns > const int checkImageHeight = 64; > GLubyte [,,] checkImage; // Texture image data > GLuint texName; > > private static uint8[,,] makeCheckImage (int width = 64, int height = 64) { > > > > uint8[,,] check_image = new uint8[height,width,4]; > > > > for ( var i = 0 ; i < height ; i++ ) {... > void init() > { > glClearColor (0.0f, 0.0f, 0.0f, 0.0f); > glShadeModel(GL_FLAT); > glEnable(GL_DEPTH_TEST); > > makeCheckImage(); > glPixelStorei(GL_UNPACK_**ALIGNMENT, 1); > > glGenTextures(1, (GLuint[])texName); > glBindTexture(GL_TEXTURE_2D, texName); > > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); > glTexImage2D(GL_TEXTURE_2D, 0, (GLint)GL_RGBA, checkImageWidth, > checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); > } > > void display() > { > glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); > glEnable(GL_TEXTURE_2D); > glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); > glBindTexture(GL_TEXTURE_2D, texName); > glBegin(GL_QUADS); > glTexCoord2f(0.0f, 0.0f); glVertex3f(-2.0f, -1.0f, 0.0f); > glTexCoord2f(0.0f, 1.0f); glVertex3f(-2.0f, 1.0f, 0.0f); > glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, 1.0f, 0.0f); > glTexCoord2f(1.0f, 0.0f); glVertex3f(0.0f, -1.0f, 0.0f); > > glTexCoord2f(0.0f, 0.0f); glVertex3f(1.0f, -1.0f, 0.0f); > glTexCoord2f(0.0f, 1.0f); glVertex3f(1.0f, 1.0f, 0.0f); > glTexCoord2f(1.0f, 1.0f); glVertex3f(2.41421f, 1.0f, -1.41421f); > glTexCoord2f(1.0f, 0.0f); glVertex3f(2.41421f, -1.0f, -1.41421f); > glEnd(); > glFlush(); > glDisable(GL_TEXTURE_2D); > } > > void reshape(int w, int h) > { > glViewport(0, 0, (GLsizei) w, (GLsizei) h); > glMatrixMode(GL_PROJECTION); > glLoadIdentity(); > gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 30.0); > glMatrixMode(GL_MODELVIEW); > glLoadIdentity(); > glTranslatef(0.0f, 0.0f, -3.6f); > } > > void keyboard (uchar key, int x, int y) > { > switch (key) { > case 27: > //exit(0); > break; > default: > break; > } > } > > void main(string[] args) > { > glutInit(ref args.length, args); > glutInitDisplayMode(GLUT_**SINGLE | GLUT_RGBA | GLUT_DEPTH); > glutInitWindowSize(250, 250); > glutInitWindowPosition(100, 100); > glutCreateWindow("checker"); > init(); > glutDisplayFunc(display); > glutReshapeFunc(reshape); > glutKeyboardFunc(keyboard); > glutMainLoop(); > } > Thanks Tom On 07/02/2013 07:02 PM, Evan Nemerson wrote: > > On Tue, 2013-07-02 at 18:49 -0500, Thomas F Steinhauer wrote: >> >> I tried your code as you sug... _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list