 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tanju ÖZGÜR Guest
|
Posted: Tue Feb 07, 2006 10:01 am Post subject: OpenGL |
|
|
Hi folk !
1.) In OpenGL, what can I do to fix the problem at the attached file, edges
rendering doesn't satisfy me and also when I'm rotating objects (or
translating) edges seem very ragged.
Thnx! |
|
| Back to top |
|
 |
Andrew Jameson Guest
|
Posted: Tue Feb 07, 2006 11:01 am Post subject: Re: OpenGL |
|
|
You might consider using ARB_MULTISAMPLE, there's an example at :
http://nehe.gamedev.net/lesson.asp?index=10
You could also turn on the card's anti-aliasing (if supported) but this can
be difficult to control from an application. I recollect some examples that
do this and I think that they're available from the above link.
Anti-aliasing and multi-pass rendering can introduce a significant
performance hit and another suggestion (if you're running in fullscreen) is
simply to increase the screen resolution which is what we do with our OpenGL
product.
There are a few other techniques for edge blurring and I would strongly
suggest posting this question on the OpenGL forum at www.opengl.org.
Andrew
"Tanju VZG\R" <tanjuozgur (AT) yahoo (DOT) com> wrote in message
news:43e86209$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi folk !
1.) In OpenGL, what can I do to fix the problem at the attached file,
edges rendering doesn't satisfy me and also when I'm rotating objects (or
translating) edges seem very ragged.
Thnx!
|
|
|
| Back to top |
|
 |
Andrew Jameson Guest
|
Posted: Tue Feb 07, 2006 11:01 am Post subject: Re: OpenGL |
|
|
Just refreshing my memory - I gave up fighting the jaggies but there's lots
of ideas around :
http://www.edm2.com/0603/opengl.html
Try Googling !
Andrew
| Quote: | 1.) In OpenGL, what can I do to fix the problem at the attached file,
edges rendering doesn't satisfy me and also when I'm rotating objects (or
translating) edges seem very ragged.
Thnx! |
|
|
| Back to top |
|
 |
Tanju ÖZGÜR Guest
|
Posted: Tue Feb 07, 2006 1:02 pm Post subject: Re: OpenGL |
|
|
Thnxs helping me,
It doesn't sound like a good idea to turn on anti-aliasing which doesn't
eliminate the jaggy edges but blurr them with nearby pixels. It seems to me
that I didn't specify the front and back surface of objects so that, drawing
for back and front surface is made randomly. First front surface is drawn
and then back surface is drawn on top of the front surface or vice versa.
Could this be a thing that I'm missing in my program ?
"Andrew Jameson" <softspotsoftwareNO (AT) SPAMgmail (DOT) com>, haber iletisinde
şunları yazdı:43e873b6 (AT) newsgroups (DOT) borland.com...
| Quote: | Just refreshing my memory - I gave up fighting the jaggies but there's
lots of ideas around :
http://www.edm2.com/0603/opengl.html
Try Googling !
Andrew
1.) In OpenGL, what can I do to fix the problem at the attached file,
edges rendering doesn't satisfy me and also when I'm rotating objects
(or translating) edges seem very ragged.
Thnx!
|
|
|
| Back to top |
|
 |
Andrew Jameson Guest
|
Posted: Tue Feb 07, 2006 1:02 pm Post subject: Re: OpenGL |
|
|
I think that we'd have to see your code to have a chance of helping
further - just need the rendering code, although even though you're not
culling faces, I can't see why that would generate jaggies.
Anti-aliasing comes in many guises and it doesn't necessarily simply 'blur'
edges.
If you're new to the world of OpenGL, I listed a load of good OpenGL sites
in a previous thread but top of my list is :
http://www.sulaco.co.za/
You'll find lots of excellent examples by the late Jan Horn ...
Andrew |
|
| Back to top |
|
 |
Tanju ÖZGÜR Guest
|
Posted: Tue Feb 07, 2006 2:03 pm Post subject: Re: OpenGL |
|
|
Actually rendering code is nothing but drawing primitive shapes like box,
cylinder, etc, where I'm setting the culling is at the initialization
routine .Below you can find it :
/////////////////////////////
procedure GLInit;
const
light0_position:TGLArrayf3=( 0.0,0.0,300.0);
ambient: TGLArrayf3=( 1.0, 1.0, 1.0);
specular :TGLArrayf3 = (0.0,0.0,0.0);
sh :GLFloat = 0.4;
begin
// set viewing projection
glMatrixMode(GL_PROJECTION);
gluPerspective(80,2,0.1,15000);
// position viewer
glViewport(0,0,OpenGLForm.Width,OpenGLForm.Height);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_DEPTH_TEST);
glEnable(gl_Lighting);
glShadeModel(gl_smooth);
glEnable(gl_Cull_face);
glCullface(gl_back);
glDepthFunc(gl_lequal);
glLightfv(GL_LIGHT0, GL_POSITION, @light0_position);
glLightfv(GL_LIGHT0, GL_ambient, @ambient);
glLightfv(GL_LIGHT0, GL_specular, @specular);
glLightfv(gl_light0,gl_shininess,@sh);
glEnable (GL_LIGHT0);
end;
////////////////////
Above if I disable the culling the result is completely a mess. "Gl_Back"
value works better than setting "gl_front"
"Andrew Jameson" <softspotsoftwareNO (AT) SPAMgmail (DOT) com>, haber iletisinde
şunları yazdı:43e894c5$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I think that we'd have to see your code to have a chance of helping
further - just need the rendering code, although even though you're not
culling faces, I can't see why that would generate jaggies.
Anti-aliasing comes in many guises and it doesn't necessarily simply
'blur' edges.
If you're new to the world of OpenGL, I listed a load of good OpenGL sites
in a previous thread but top of my list is :
http://www.sulaco.co.za/
You'll find lots of excellent examples by the late Jan Horn ...
Andrew
|
|
|
| Back to top |
|
 |
Andrew Jameson Guest
|
Posted: Tue Feb 07, 2006 3:01 pm Post subject: Re: OpenGL |
|
|
Nothing too startling here ... actually need the rendering loop and not the
init ... you are correct using GL_BACK for culling and I'd suggest removing
the glDepthFunc line ... I'd really suggest that you start from one of Jan
Horns simple examples and he produced a good base template for Delphi :
http://www.sulaco.co.za/opengl5.htm
and you might like to take a look at NeHe's tutorials ... many of which are
downloadable as Delphi projects :
http://nehe.gamedev.net/
Tutorial 5 would be a good start and then you could compare whether the
'jaggies' are still visible on those examples.
Andrew |
|
| Back to top |
|
 |
Tanju ÖZGÜR Guest
|
Posted: Tue Feb 07, 2006 4:02 pm Post subject: Re: OpenGL |
|
|
okay here is the acctual code which I call to draw object after GLInit();
and just before SwapBuffers(....)
but I couldn't succed to understand what does it help for as long as it's
simple.
/////////////////
procedure TOpenGLForm.DrawColumn(ColObj: TObject2D);
function getNormal(p1,p2,p3:TGLArrayf3):TGLArrayf3;
var a,b:TGLArrayf3;
begin
//make two vectors
a[0]:=p2[0]-p1[0]; a[1]:=p2[1]-p1[1]; a[2]:=p2[2]-p1[2];
b[0]:=p3[0]-p1[0]; b[1]:=p3[1]-p1[1]; b[2]:=p3[2]-p1[2];
//calculate cross-product
Result[0]:=a[1]*b[2]-a[2]*b[1];
Result[1]:=a[2]*b[0]-a[0]*b[2];
Result[2]:=a[0]*b[1]-a[1]*b[0];
end;
var
a1,a2,a3,a4,a5,a6,a7,a8 :TGLArrayf3;
TmpWidth,TmpHeight :Single;
n1,n2,n3,n4,n5,n6,n7,n8 :TGlArrayf3;
mat :TGLArrayf3;
begin
TmpWidth := ColObj.SEP.Width; TmpHeight :=ColObj.SEP.Height;
mat[0] := 0; mat[1] := 0.6; mat[2] := 0.4;
a1[0] := ColObj.Points[0].X; a1[1] :=ColObj.Points[0].Y; a1[2] :=
ColObj.SEP.PointI.Z;
a2[0] := ColObj.Points[0].X+TmpWidth; a2[1] :=ColObj.Points[0].Y; a2[2]
:= ColObj.SEP.PointI.Z;
a3[0] := ColObj.Points[1].X; a3[1] := ColObj.Points[1].Y; a3[2] :=
ColObj.SEP.PointI.Z;
a4[0] := ColObj.Points[0].X; a4[1] := ColObj.Points[1].Y; a4[2] :=
ColObj.SEP.PointI.Z;
a5[0] := ColObj.Points[0].X; a5[1] :=ColObj.Points[0].Y; a5[2] :=
ColObj.SEP.PointJ.Z;
a6[0] := ColObj.Points[0].X+TmpWidth; a6[1] :=ColObj.Points[0].Y; a6[2]
:= ColObj.SEP.Pointj.Z;
a7[0] := ColObj.Points[1].X; a7[1] := ColObj.Points[1].Y; a7[2] :=
ColObj.SEP.PointJ.Z;
a8[0] := ColObj.Points[0].X; a8[1] := ColObj.Points[1].Y; a8[2] :=
ColObj.SEP.PointJ.Z;
n1 := GetNormal(a1,a2,a3); n2 := GetNormal(a5,a6,a7); n3 :=
GetNormal(a1,a5,a ;
n4 := GetNormal(a1,a2,a6); n5 := GetNormal(a4,a8,a7); n6 :=
GetNormal(a2,a3,a7);
GlEnable(gl_Normalize);
glMaterialfv(gl_front,gl_ambient,@mat);
glBegin(gl_Quads);
glNormal3fv(@n1);
glvertex3fv(@a1); glvertex3fv(@a2); glvertex3fv(@a3);glvertex3fv(@a4);
glNormal3fv(@n2);
glvertex3fv(@a5); glvertex3fv(@a6); glvertex3fv(@a7);glvertex3fv(@a ;
glNormal3fv(@n3);
glvertex3fv(@a1); glvertex3fv(@a5); glvertex3fv(@a ;glvertex3fv(@a4);
glnormal3fv(@n4);
glvertex3fv(@a1); glvertex3fv(@a2); glvertex3fv(@a6);glvertex3fv(@a5);
glNormal3fv(@n5);
glvertex3fv(@a4); glvertex3fv(@a ; glvertex3fv(@a7);glvertex3fv(@a3);
glNormal3fv(@n6);
glvertex3fv(@a2); glvertex3fv(@a3); glvertex3fv(@a7);glvertex3fv(@a6);
glEnd;
end;
"Andrew Jameson" <softspotsoftwareNO (AT) SPAMgmail (DOT) com>, haber iletisinde
şunları yazdı:43e8b258 (AT) newsgroups (DOT) borland.com...
| Quote: | Nothing too startling here ... actually need the rendering loop and not
the init ... you are correct using GL_BACK for culling and I'd suggest
removing the glDepthFunc line ... I'd really suggest that you start from
one of Jan Horns simple examples and he produced a good base template for
Delphi :
http://www.sulaco.co.za/opengl5.htm
and you might like to take a look at NeHe's tutorials ... many of which
are downloadable as Delphi projects :
http://nehe.gamedev.net/
Tutorial 5 would be a good start and then you could compare whether the
'jaggies' are still visible on those examples.
Andrew
|
|
|
| Back to top |
|
 |
Andrew Jameson Guest
|
Posted: Tue Feb 07, 2006 7:01 pm Post subject: Re: OpenGL |
|
|
Hi,
I'm a bit pushed for time ... so I am simply reiterating my suggestion ...
download a few tutorial demos ... you'll acquire a faster understanding than
continuing to try to get this example to work !
Andrew |
|
| Back to top |
|
 |
Igor Raskin Guest
|
Posted: Tue Feb 07, 2006 8:02 pm Post subject: Re: OpenGL |
|
|
"Tanju ÖZGÜR" <tanjuozgur (AT) yahoo (DOT) com> wrote in message
news:43e86209$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi folk !
1.) In OpenGL, what can I do to fix the problem at the attached file,
edges rendering doesn't satisfy me and also when I'm rotating objects (or
translating) edges seem very ragged.
|
What are the coordinate ranges of the quads that you are drawing?
What you describe looks like the z-buffering not able to correctly determine
the visiblity of shapes fragments. This happens when the competing quads are
are located near the far end of the world (15000).
| Quote: | gluPerspective(80,2,0.1,15000);
|
Igor |
|
| Back to top |
|
 |
Tanju ÖZGÜR Guest
|
Posted: Wed Feb 08, 2006 7:01 am Post subject: Re: OpenGL |
|
|
| Quote: | What are the coordinate ranges of the quads that you are drawing?
The coordinates of objects didn't exceed the max range, they are ranging |
from 100 to 5000.
But anyway your idea has given me the entry point, I know that it wasn't a
rocket science, not far range but setting the near range value from 0.1 to 1
gives me the satisfying results, value 2 give much and much better solution,
Thank you all ,
"Igor Raskin" <igorr (AT) web_lakes (DOT) com>, haber iletisinde şunları
yazdı:43e8f7cd$1 (AT) newsgroups (DOT) borland.com...
| Quote: | "Tanju ÖZGÜR" <tanjuozgur (AT) yahoo (DOT) com> wrote in message
news:43e86209$1 (AT) newsgroups (DOT) borland.com...
Hi folk !
1.) In OpenGL, what can I do to fix the problem at the attached file,
edges rendering doesn't satisfy me and also when I'm rotating objects (or
translating) edges seem very ragged.
What are the coordinate ranges of the quads that you are drawing?
What you describe looks like the z-buffering not able to correctly
determine
the visiblity of shapes fragments. This happens when the competing quads
are
are located near the far end of the world (15000).
gluPerspective(80,2,0.1,15000);
Igor
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|