I wasn’t programming during the last few days due to my exams. Today - hopefully - was the last one. I started doing this point sprite thing right from the scratch. In my last program, they were an add-on. This one is all about them - no interaction with anything possible. No arrays, no vertex arrays, no pbuffers, no VBO, no Addr() operator, so please don’t even mention them…
Fragment and vertex shaders are the same. The program (GL related thing) is as follows:
procedure InitGL;
var
TabI : array[0…2] of integer;
begin
InitOpenGL;
InitDevIL;
ilinit;
h_DC := getDC(Form1.Handle);
h_RC := CreateRenderingContext(h_DC,[opDoubleBuffered],32,24,0,0,0,0);
ActivateRenderingContext(h_DC,h_RC);
SpriteTexture := iltexloader.LoadILReadyToUseTextureRGBA(‘sprite.bmp’);
glBindTexture(GL_TEXTURE_2D,SpriteTexture);
glTexEnvi (GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
SpriteVertexShader := dotshaders.dotGLSLLoadShaderFromFile(‘SpriteVertexShader.shader’,GL_VERTEX_SHADER_ARB);
SpriteFragmentShader := dotshaders.dotGLSLLoadShaderFromFile(‘SpriteFragmentShader.shader’,GL_FRAGMENT_SHADER_ARB);
TabI[0] := SpriteVertexShader;
TabI[1] := SpriteFragmentShader;
SpriteShader := dotshaders.dotGLSLLinkPrograms(TabI);
SpriteTextureHandle := dotshaders.dotGLSLUniformLocation(SpriteShader,‘SpriteTexture’);
glUseProgramObjectARB(SpriteShader);
glUniform1iARB(SpriteTextureHandle,0);
ResizeGL;
end;
procedure DeInitGL;
begin
destroyRenderingContext(h_RC);
end;
procedure ResizeGL;
var
x,y : integer;
begin
if (h_RC <> 0) then
begin
x := Form1.ClientWidth;
y := Form1.ClientHeight;
glViewport(0,0,x,y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
gluPerspective(55,x/y,1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
end;
end;
procedure DrawGl;
var
p1: integer;
begin
glClear(GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT);
glLoadIdentity;
gluLookAt(10,10,10,0,0,0,0,1,0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_POINT_SPRITE_ARB);
glEnable(GL_BLEND);
glEnable(dglopengl.GL_VERTEX_PROGRAM_POINT_SIZE_ARB);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glEnable(GL_TEXTURE_2D);
glBegin(GL_POINTS);
for p1 := 1024 downto 1 do
begin
glVertex3f(p1/256,-p1/256,-p1/256);
end;
glEnd;
swapBuffers(h_DC);
end;
When the loop is 1024 or less IT DOES REALLY WORK, so EVERYTHING SEEMS to be setup correctly. But again, when I change to 2048 : crash… Any ideas? My card seems to work correctly with other aps. What is going on?