Main Page | Report this Page
Computers Forum Index  »  Computer - Graphics - API (Opengl)  »  Following opengl code does not work with vertex shader...
Page 1 of 1    

Following opengl code does not work with vertex shader...

Author Message
Skybuck Flying...
Posted: Wed Sep 23, 2009 4:49 am
Guest
Ok,

I just tested it with nehe code... and it does work :)

Well at least the vertex shader does work..

But what if vertex+pixel shader is combined ?!

Hmm still have to test that ! ;)

Problem is probably somewhere with the combination of it.

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Yes, so my final conclusion is:

"Cartesian coordinate system" is relative/related to the viewer position.

It's not an absolute coordinate system.

The viewer could be upside down, lieing on the ground or whatever...

The coordinate system for the viewer would remain the same...

But in reality the points would rotate... as the viewer rotates...

Therefore for the viewer the points do not seem to rotate... (Viewer is
holding a painting)

For the outside world it would be different ! ;)

Therefore this coordinate system could also be called a "virtual coordinate
system".

It takes place in the perception of the viewer ! Wink :)

A nice example is computer games... where people all around the world are
playing in a virtual room...

They all see the room the same way as long as they standing up straight...

While in reality their positions is rotated all across the world ! ;)

Too funny ! Wink :)

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Well now for the first time... I do see something in opengl...

So I guess opengl's state machine is good after all ! :)

I have no explanation why my other code didn't work expect the following:

Some kind of problem with the shaders.

Well I am now much better at writing shaders so hopefully this issue belongs
to the past.

But there is also so other new code in there in the opengl stuff but ok...

So far me surprised and happy that it's working after all !

Very nice ! =D

Bye,
Skybuck =D
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Hmm the mixing so far seems to work.. but this is for a "normal/standard" 3d
scene...

Maybe in ortho 2d it might fail... not sure yet...

Now I have to try out the ortho 2d stuff ;)

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Hmm now I seem to have a new problem...

Texture coordinates and even all coordinates not being passed to the pixel
shader ?!?

Hard to debug... with no debugger and no writeln... hmm...

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Ok,

Now it's finally working...

I think I get it now....

It's something like:

// do vertex stuff first completely

get vertex profile

set optimal vertex profile

load vertex program

get vertex parameter

// do fragment stuff next completely

get fragment profile

set optimal fragment profile

load fragment program

// then when drawing

// do vertex program first completely

enable vertex profile

bind vertex program

// do shader program next completely

enable shader profile

bind shader profile

In the past I did it as follows:

enable vertex
enable fragment

bind vertex
bind fragment

Apperently opengl's state machine is crap and can't handle it like that...

I shall try the last way one more time to confirm that that was the problem
;)

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Also in perspective vs ortho2d the y and z axis seem to be flipped... this
is a bit unfortunate... Sad ;)

But at least in otho2d x=x and y=y it seems ! ;)

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Ok,

Since there is no texture yet I changed something from position... already
did that...

This time changed pixel shader formula... it does seem to be working a bit !
;)

Possible conclusions:

When there is no texture loaded then opengl will not pass any texture
coordinates ?

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Actually I think the 3d might have been a little weirdness by nehe or just
the example was kinda weird...

The example was using x and z...

The weird thing is the Z goes into the screen ?

Well cavemen would have drawn on the floor...

So I would assume the x and y are on the floor... and the z is pointing
towards the sky... into the air...

Because the monitor is usually up straight...

This means the x is still the same... but the screen y is now the world z...

and the world y is now the "screen opengl z"...

This is kinda weird because I just did a test not sure if it was correct...

But opengl seems to assume the x is on the floor and the y is pointing
towards the sky.... and the z goes into the screen...

if the monitor was flat on the ground then this would indeed make sense...

But ultimately it doesn't matter... now that I use x and y only in the
example...

the 3d example looks like the 2d example so all is good now I think ! ;)

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Then again...

Cavemen could have drawn on walls first too ;)

Or the coordinates system was invented by people drawing on paintings ;)

In that light/context it would make sense to say the x is horizontal, the y
is straight up and the z is into the screen ;)

From now on I will pretend the coordinate system was invented by painters
painting on a canvas on a standard, standing straight up ! Wink :)

Bye,
Skybuck =D
 
Skybuck Flying...
Posted: Wed Sep 23, 2009 5:16 am
Guest
Yes this link seems to have a nice picture:

http://www.falloutsoftware.com/tutorials/gl/gl0.htm

It's also called:

"Cartesian coordinate system"

Apperently invented by a poor ill man thinking about his flies on the
ceiling ! Wink SmileSmile:)

http://thesaurus.maths.org/mmkb/entry.html?action=entryById&id=785

Now I am curious why he choose the x,y and z like that ! ;)

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Thu Sep 24, 2009 5:16 am
Guest
Ok this works:

procedure CreateVertexPoints(ParaWidth: integer; ParaHeight: integer);
var
vX: integer;
vY: integer;
// vZ : integer;
begin
glBegin(GL_POINTS);
for vY := 0 to ParaHeight - 1 do
begin
for vX := 0 to ParaWidth - 1 do
begin
glVertex3f( vX, vY, 0 ); // could be 2f as well for 2d version Wink
// set vertex position coordinates

glTexCoord2f( vX, vY ); // set vertex texture coordinates
end;
end;
glEnd;
end;

Bye,
Skybuck.
 
Skybuck Flying...
Posted: Thu Sep 24, 2009 5:16 am
Guest
It seems the texture coordinates have to be set seperately with a special
opengl api call per vertex or so:

"glTexCoord".

This should then set the texture coordinates and be visible inside the
vertex shader ! ;)

I will try so now to see if it works ! ;)

Bye,
Skybuck.
 
 
Page 1 of 1    
All times are GMT
The time now is Sat Nov 28, 2009 12:32 am