opengl

0

dlaczego po dolaczeniu w sekcji uses - opengl, przy probie kompilacji kompilator w pliku opengl.pas pokazuje errora (Left side cannot be assigned to) w przypisaniu:
LastPixelFormat:=0; ???????

dopisane:

No tak, bo to jest stala. Wiec po co autor kodu chce zmieniac stala??

Czegos tu nie czaje :(.

0

a ja tam wywaliłem to co mu nie pasowalo ... :)

0

tutaj masz kod na inicjalizacje i usnuniecie trybu opengl z okna oraz kilka dodartkowych funkcji

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, OpenGL,
ExtCtrls, StdCtrls, Textures, DXInput, DXClass;

type
Tpanel1 = class(TForm)
DXInput1: TDXInput;
DXInput2: TDXInput;
Button1: TButton;
Button2: TButton;
procedure FormResize(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private

public
rc : HGLRC;
dc : HDC;
procedure glDraw;
procedure tworz_gl_int;
procedure destroy_gl_int;
procedure Idle(Sender: TObject; var Done: Boolean);
procedure exitme;
end;

var
panel1: Tpanel1;
ican : boolean = false;
usem : boolean = false;
can_draw : boolean = false;
X : glFloat = 0;
Z : glFloat = 0;
y : glfloat = 0;
Heading : glFloat = 0;
MouseSpeed : glfloat = 3;
MoveSpeed : glFloat = 0.2;
filename : string;
glop : glfloat;
fov : glfloat = 90.0; ///ja lubie 110 ale to program dla wszystkich :/
z_near : glfloat = 0.01; //nie rysuj dopiero od pozycji 0,01 od naszej kamery
z_far : glfloat = 4000.0; //i rysuj 4 km dalej :P
cr : byte = 0; //czerwony
cg : byte = 0; ///zielony
cb : byte = 0; //niebieski
ca : byte = 0; //alpha
konsola : gluint;
eexit : boolean = false;
console_mode : boolean = false;

implementation
uses move_unit;

{$R *.DFM}

procedure glInit();
begin
glClearColor(cr, cg, cb, ca); // Background
glShadeModel(GL_SMOOTH);
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
end;

procedure tpanel1.destroy_gl_int;
begin
eexit := true;
exitme;
end;

procedure tpanel1.tworz_gl_int;
var pfd : TPIXELFORMATDESCRIPTOR;
pf : Integer;
begin
eexit := false;
dc:=GetDC(Panel1.Handle);

pfd.nSize:=sizeof(pfd);
pfd.nVersion:=1;
pfd.dwFlags:=PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER or 0;
pfd.iPixelType:=PFD_TYPE_RGBA;
pfd.cColorBits:=32;

pf :=ChoosePixelFormat(dc, @pfd);
SetPixelFormat(dc, pf, @pfd);

rc :=wglCreateContext(dc);
wglMakeCurrent(dc,rc);
with pfd do
begin
nSize := SizeOf(TPIXELFORMATDESCRIPTOR);
dwFlags := PFD_DRAW_TO_WINDOW
or PFD_SUPPORT_OPENGL
or PFD_DOUBLEBUFFER;
iPixelType := PFD_TYPE_RGBA;
cColorBits := 32;
cDepthBits := 32;
end;

glInit;
Panel1.OnResize(nil);
Application.OnIdle := Idle;
end;

procedure tpanel1.exitme;
begin
wglMakeCurrent(0,0);
wglDeleteContext(rc);
end;

procedure Tpanel1.glDraw();
begin
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//rotate
glRotate(Heading, 1, 0, 0);
glrotate(glop,0,1,0);
glTranslatef(X, Y, Z);
//refresh
if eexit = false then
begin
if usem = true then
begin
dxinput1.update;
if (isup in dxinput1.states) then heading := heading - mousespeed;
if (isdown in dxinput1.states) then heading := heading + mousespeed;
if (isleft in dxinput1.states) then glop := glop - mousespeed;
if (isright in dxinput1.states) then glop := glop + mousespeed;
//center mouse
if ((isup in dxinput1.states) or (isright in dxinput1.states) or (isleft in dxinput1.states) or (isdown in dxinput1.states) ) then SetCursorPos(panel1.width - 60 ,panel1.height-60);
end;
dxinput2.update;
//keyb move
if (isup in dxinput2.states) then move_przod;
if (isdown in dxinput2.states) then move_tyl;
if (isleft in dxinput2.states) then move_left;
if (isright in dxinput2.states) then move_right;
//mouse move
if heading > 90 then heading := 90;
if heading 360 then glop := 0;
if glop

0

Z tym przypisywaniem wartości stałej to jest tak, że w starszych wersjach Delphi (np. w 4) do stałych można było przypisywać wartości, używając ich np. w procedurach jako zmiennych z inicjalizacją. W nowszych wersjach Delphi zlikwidowano ten myk i trzeba zmieniać te stałe na zmnienne (chociaż możliwe że istnieje jakiś przełącznik komplilacji który to zmienia, ale nie mam pojącia jaki).

0

(chociaż możliwe że istnieje jakiś przełącznik komplilacji który to zmienia, ale nie mam pojącia jaki).

Istnieje. Jak zwykle w takich przypadkach polecam F1.

1 użytkowników online, w tym zalogowanych: 0, gości: 1