[fpc-pascal] Problem with OpenGL drawing on Linux

Darius Blaszyk dhkblaszyk at zeelandnet.nl
Fri Dec 10 00:34:10 CET 2010


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.





More information about the fpc-pascal mailing list