DGL
https://delphigl.com/forum/

OpenGL 3.x cube problem
https://delphigl.com/forum/viewtopic.php?f=19&t=8881
Seite 1 von 1

Autor:  noeska [ So Dez 20, 2009 20:52 ]
Betreff des Beitrags:  OpenGL 3.x cube problem

Next in my opengl3.x adventures is trying to display a cube, but i must be doing something wrong.

The original is available from: http://nopper.tv/opengl_3_2.html (example03)

This is my attempt: http://www.noeska.net/downloads/Ogl3Cube1.zip .

Who can help me to find out what i do wrong. Also i found the original not to be logic as in the render part i do not see references as to what is rendered?

Autor:  noeska [ Mo Dez 21, 2009 20:08 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

For now i suspect the following:
g_vertexLocation := glslsimpleprog.GetAttribLocation('vertex');
g_normalLocation := glslsimpleprog.GetAttribLocation('normal');
both give -1 as result. But why?
The attrib is availeable in the vertex shader and the vertex shader compiles succesfully... Only the fragment shader gives an warning...
Now i could set an attrib location, but this should work also (even in opengl 2.x ?)

Autor:  Lord Horazont [ Mo Dez 21, 2009 20:11 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

Did you bind the Shader program properly?

greetings

Autor:  noeska [ Mo Dez 21, 2009 20:38 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

I think i do, but i am not sure...

Autor:  noeska [ Di Dez 22, 2009 19:49 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

with getting some wrong results from glGetAttribLocation i was hinted to look in the dglopengl header on the pgd forum and indeed there is a bug as char is specified there as string instead of PGLChar.

OpenGL 3.2 - Headertranslation
Version 3.2.2
Date : 16.12.2009
row 6577 should be:
TglGetAttribLocation = function(programObj: GLhandle; char: PGLChar): glint; {$IFDEF DGL_WIN}stdcall; {$ELSE}cdecl; {$ENDIF}

Not that my cube shows yet, i need to add some more code to the cube example ...

What do you mean by bind?
glLinkProgramARB(FProgramObject);
or
glUseProgram(FProgramObject);

or both?

Autor:  Lord Horazont [ Mi Dez 23, 2009 22:08 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

I meant the glUseProgram call.

greetings

Autor:  noeska [ Do Dez 24, 2009 19:37 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

I changed my example a bit by adding an vao object.
But it does not work yet :-(
Still a black screen like the original cpp example on my ati, but not a cube as promised.

Here is my new attempt: http://www.noeska.net/downloads/Ogl3Cube2.zip

Autor:  noeska [ Fr Dez 25, 2009 19:24 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

Found some bugs in passing the arrays trough the calculations. Fixed that.
But still no cube :-(

Latest version:
http://www.noeska.net/downloads/Ogl3Cube3.zip

Who is willing to test the code on nvidia?

Autor:  noeska [ Fr Dez 25, 2009 23:34 ]
Betreff des Beitrags:  Re: OpenGL 3.x cube problem

Found the real problem :-)
In the resizewindow part i already 'publish' the projectionlocation matrix, but the location is not known yet and default being 0. But when requested its location becomes 1 resulting that it is overwritten by the modelview matrix that gets location 0. So as a workaround i calculate the matrix as before but only 'publish' it in the init part.
And next the cube showed up :-)

Final source: http://www.noeska.net/downloads/Ogl3Cube4.zip

[edit]fixed typo in url[/edit]

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/