0
저는 리눅스에서 Lazarus를 사용합니다. 아무도 도와주세요. 나는 문제가있다. LasOpenGLContext를 설치했습니다. 구성 요소 패널에는 "OpenGL Controll"이 있습니다. 그리고 저는 간단한 큐브를 그려보고 싶습니다. 그러나 나는 그것을 할 수 없다. 나는 raised an exception class 'External:SIGSEGV'
무엇이 잘못 되었나요? 아이디어가 있으면 제발.glClearColor 예외가 발생했습니다. TOpenGLComponent 나사로
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은 컨텍스트가 스레드 로컬 저장소를 사용하는 경향이있다. 의미는 당신이 호출 스레드에서 활성화되어 있지 않은 경우 잘못된 메모리 액세스를 포함 할 수있는 정의되지 않은 결과를 기대합니다. –