J'utilise Lazarus (sous Linux) S'il vous plaît, aidez-moi. J'ai un problème. J'ai installer LasOpenGLContext. Il y a "Contrôle OpenGL" sur le panneau des composants. Et je souhaite dessiner un simple cube. Mais je ne peux pas le faire. Je reçois raised an exception class 'External:SIGSEGV'
Quel est le problème? S'il vous plaît, si des idées.glClearColor levée exception TOpenGLComponent Lazarus
unit Ex1;
{$mode objfpc}{$H+}
{$LinkLib GL}
interface
uses
Classes, SysUtils, FileUtil, OpenGLContext, Forms, Controls, Graphics, gl, glu, Glut,
Dialogs, ExtCtrls, LazOpenGLContext, LCLType;
type
{ Tfrm }
Tfrm = class(TForm)
OpenGLControl1: TOpenGLControl;
Timer: TTimer;
procedure FormCreate(Sender: TObject);
procedure TimerTimer(Sender: TObject);
private
{ private declarations }
public
cube_rotation: GLFloat;
Speed: Double;
{ public declarations }
end;
var
frm: Tfrm;
implementation
{$R *.lfm}
{ Tfrm }
procedure Tfrm.FormCreate(Sender: TObject);
begin
glClearColor(1.0, 1.0, 1.0, 1.0); // here brakepoint raised an exception class 'External:SIGSEGV'
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, double(width)/height, 0.1, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0,-6.0);
glRotatef(cube_rotation, 1.0, 1.0, 1.0);
glBegin(GL_QUADS);
glColor3f(0.0,1.0,0.0);
glVertex3f(1.0, 1.0,-1.0);
glVertex3f(-1.0, 1.0,-1.0);
glVertex3f(-1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0,0.5,0.0);
glVertex3f(1.0,-1.0, 1.0);
glVertex3f(-1.0,-1.0, 1.0);
glVertex3f(-1.0,-1.0,-1.0);
glVertex3f(1.0,-1.0,-1.0);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0,0.0,0.0);
glVertex3f(1.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glVertex3f(-1.0,-1.0, 1.0);
glVertex3f(1.0,-1.0, 1.0);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0,1.0,0.0);
glVertex3f(1.0,-1.0,-1.0);
glVertex3f(-1.0,-1.0,-1.0);
glVertex3f(-1.0, 1.0,-1.0);
glVertex3f(1.0, 1.0,-1.0);
glEnd();
glBegin(GL_QUADS);
glColor3f(0.0,0.0,1.0);
glVertex3f(-1.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0,-1.0);
glVertex3f(-1.0,-1.0,-1.0);
glVertex3f(-1.0,-1.0, 1.0);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0,0.0,1.0);
glVertex3f(1.0, 1.0,-1.0);
glVertex3f(1.0, 1.0, 1.0);
glVertex3f(1.0,-1.0, 1.0);
glVertex3f(1.0,-1.0,-1.0);
glEnd();
cube_rotation += 5.15 * Speed;
OpenGLControl1.SwapBuffers;
end;
procedure Tfrm.TimerTimer(Sender: TObject);
begin
end;
end.
OpenGL rendre les contextes ont tendance à utiliser le stockage local-fil. Ce qui signifie que si vous n'en avez pas un actif dans le thread appelant, attendez-vous à des résultats indéfinis qui peuvent inclure l'accès à la mémoire invalide. –