I am trying to fill a texture before passing it to GLSL.
Normally the backbuffer texture is blank initialised to nil like
Code: glGenTextures(1,@backbuffer); glBindTexture(GL_TEXTURE_2D,backbuffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imwidth, imheight, 0, GL_RGBA,GL_UNSIGNED_BYTE,nil);
But for a certain shader I want to be able to fill backbuffer.
I define an array of unsigned byte type
Code: background:array of array of TGLVectorub4; backgroundcolor:TGLVectorub4;
And then change the texture code to fill it
Code: glGenTextures(1,@backbuffer); glBindTexture(GL_TEXTURE_2D,backbuffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); setlength(background,imwidth,imheight); for yloop:=0 to imheight-1 do begin for xloop:=0 to imwidth-1 do begin backgroundcolor[0]:=255; backgroundcolor[1]:=1; backgroundcolor[2]:=1; backgroundcolor[3]:=1; background[xloop,yloop]:=backgroundcolor; end; end; glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imwidth, imheight, 0, GL_RGBA,GL_UNSIGNED_BYTE,background); setlength(background,0,0);
But all I get is a blank/black backbuffer texture (the above should be red)? Any ideas on what I am doing wrong?
Thanks for any ideas.
|