Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-12

Problem with OpenGL drawing on Linux

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Darius Blaszyk

Hi,

In my code I experience a problem with drawing stippled lines with OpenGL. In the following example no line is drawn, but when I change glVertex2f(40, 480); to glVertex2f(640, 480); there is a stippled line drawn. On the other hand, when I comment glEnable(GL_LINE_STIPPLE); then a solid line is draw in both cases.

Am I making some subtle mistake in commands, or is there a bug here?

I'm using: 2.4.0-2 [2010/03/06] for i386

Regards, Darius

program gl_test;
{$mode objfpc}{$H+}
uses
  {$IFDEF UNIX} {$IFDEF UseCThreads}
    cthreads,
  {$ENDIF} {$ENDIF}
  GL, GLut;
  procedure DisplayFunc; cdecl;
  begin
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity;
    glOrtho(0, 640, 480, 0, 0, 1);
    glMatrixMode(GL_MODELVIEW);
    glDisable(GL_DEPTH_TEST);
    glShadeModel(GL_FLAT);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glClear(GL_COLOR_BUFFER_BIT);
    glLineWidth(5);
    glEnable(GL_LINE_STIPPLE);  //comment line
    glLineStipple(1, $0101);
    glBegin(GL_LINES);
    glColor3f(1, 0, 0);
    glVertex2f(0, 0);
    glVertex2f(40, 480); //change to glVertex2f(640, 480);
    glEnd;
    glDisable(GL_LINE_STIPPLE);
    glutSwapBuffers;
  end;
begin
  glutInit(@argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGBA);
  glutInitWindowSize(640, 480);
  glutInitWindowPosition(100, 100);
  glutCreateWindow('OpenGL test');
  glutDisplayFunc(@DisplayFunc);
  glClearColor(0, 0, 0, 1);
  glutMainLoop;
end.

Reply by email

Jeppe Johansen
to Darius Blaszyk

I can't spot anything inherently wrong here. Try glOrtho with near plane at -1

Otherwise, what kind of graphics driver are you running? Radeon DRI for example? A quick search seems to indicate that that one has a persisting problem with glLineStipple

Darius Blaszyk wrote
...

Reply by email

Reimar Grabowski
to Jeppe Johansen
A quick search seems to indicate that that one has a persisting problem with glLineStipple

Works as expected with the NVIDIA driver here, so the driver may really be the problem.

R.

A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Darius Blaszyk
to Reimar Grabowski

Thanks Reimar and Jeppe for your feedback. For developing, I'm using a low end PC. I fact this is also what I'm targeting for. My driver and card details are listed below.

1.3 Mesa 7.7.1
Tungsten Graphics, Inc
Mesa DRI Intel(R) 865G GEM 20091221 2009Q4 x86/MMX/SSE2

However, I would expect that only basic drawing should be supported also by low end cards. I Googled if there exists a known problem with my card but I could not find it.

Does anyone know if there is anything other I can test?

Regards, Darius

Reimar Grabowski wrote 8 lines
On Fri, 10 Dec 2010 00:47:41 +0100 Jeppe Johansen wrote: > A quick search seems to indicate that that one has a persisting > problem with glLineStipple Works as expected with the NVIDIA driver here, so the driver may really be the problem. R.

Reply by email

Darius Blaszyk
to Felipe Monteiro de Carvalho

Hi Felipe,

Felipe Monteiro de Carvalho wrote
Your program shows this in my Mac OS X: http://img64.imageshack.us/img64/640/screencapture3p.png

This is exactly what I see on windows, and what is expected. Thanks for confirming.

Strange the the window does not have a close button.

Indeed strange. Possibly a problem with GLUT. Could you try with freeGLUT? Michalis has supplied a patch to support freeGLUT more easy which was committed recently.

For those interested, I am working on a canvas class for OpenGL that descends from TFPCustomCanvas. You can find the sources here: http://scandraid.svn.sourceforge.net/viewvc/scandraid/src/branches/grape3D_0.10/ant/glcanvas.pas?revision=289&view=markup I also created a TGLFreeTypeFont which draws FreeType fonts to the GL context. This is all part of a new widget set with a dependency on OpenGL and FreeType only.

Regards, Darius

Reply by email