0
program project1;    

{$mode objfpc}{$H+}    

uses    
  {$IFDEF UNIX}    
  cthreads,    
  {$ENDIF}    
  {$IFDEF HASAMIGA}    
  athreads,    
  {$ENDIF}    
{$R *.res}    
    
  Strings,Windows,glad_gl;    
      const    
  AppName = 'WinHello';    
    
    
  function start():boolean;    
  begin    
  if not gladLoadGL() then    
  begin    
    ExitCode := -1;    
    Exit;    
  end;    
  glClearColor(0.2, 0.3, 0.4, 1.0);    
  ExitCode := 0;    
                      end;   


function WindowProc(Window: HWnd; AMessage: UINT; WParam : WPARAM;
                    LParam: LPARAM): LRESULT; stdcall; export;

     dc : hdc;
     ps : paintstruct;
     r : rect;


begin
  WindowProc := 0;

  case AMessage of
    wm_paint:
      begin
         dc:=BeginPaint(Window,@ps);
         GetClientRect(Window,@r);
         DrawText(dc,'Proba',-1,@r,
           DT_SINGLELINE or DT_CENTER or DT_VCENTER);
         EndPaint(Window,ps);
         Exit;
      end;
    wm_Destroy:
      begin
         PostQuitMessage(0);
         Exit;
      end;
  end;

  WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);
end;


function WinRegister: Boolean;
var
  WindowClass: WndClass;
begin
  WindowClass.Style := cs_hRedraw or cs_vRedraw;
  WindowClass.lpfnWndProc := WndProc(@WindowProc);
  WindowClass.cbClsExtra := 0;
  WindowClass.cbWndExtra := 0;
  WindowClass.hInstance := system.MainInstance;
  WindowClass.hIcon := LoadIcon(0, idi_Application);
  WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  WindowClass.hbrBackground := GetStockObject(WHITE_BRUSH);
  WindowClass.lpszMenuName := nil;
  WindowClass.lpszClassName := AppName;

  Result := RegisterClass(WindowClass) <> 0;
end;


function WinCreate: HWnd;
var
  hWindow: HWnd;
begin
  hWindow := CreateWindow(AppName, 'AppProba',
              ws_OverlappedWindow, cw_UseDefault, cw_UseDefault,
              cw_UseDefault, cw_UseDefault, 0, 0, system.MainInstance, nil);

  if hWindow <> 0 then begin
    ShowWindow(hWindow, CmdShow);
    ShowWindow(hWindow, SW_SHOW);
    UpdateWindow(hWindow);
  end;

  Result := hWindow;
end;


var
  AMessage: Msg;
  hWindow: HWnd;

begin
  if not WinRegister then begin
    MessageBox(0, 'Register failed', nil, mb_Ok);
    Exit;
  end;
  hWindow := WinCreate;
  if longint(hWindow) = 0 then begin
    MessageBox(0, 'WinCreate failed', nil, mb_Ok);
    Exit;
  end;

  while GetMessage(@AMessage, 0, 0, 0) do begin
    TranslateMessage(AMessage);
    DispatchMessage(AMessage);
  end;
  Halt(AMessage.wParam);

  glBegin(GL_TRIANGLES);
    glColor3f(1.0, 0.0, 0.0);
    glVertex3f(-1.0, -1.0, -2.0);

    glColor3f(0.0, 1.0, 0.0);
    glVertex3f( 0.0,  1.0, -2.0);

    glColor3f(0.0, 0.0, 1.0);
    glVertex3f( 1.0, -1.0, -2.0);
  glEnd();
end.      

project1.lpr(21,10) Error: Wrong number of parameters specified for call to "gladLoadGL"

glad_gl.pas(4264,10) Error: Found declaration: gladLoadGL(TLoadProc):Boolean;

APIs: gl=4.6
Profile: compatibility  
AIDE Lazarus 
FPC 3.2.2

I wanted to draw a triangle.

I just started learning programming. I was interested in the free pascal programming language because of the simplicity of interface

6
  • 1
    The compiler clearly tells you that at line 21 in project1.lpr you attempt to call gladLoadGL() in a different as it is declared in glad_gl.pas on line 4264: it expects 1 parameter of type TLoadProc. It's as wrong=inconsistent as trying to call your WinRegister() with parameters.
    – AmigoJack
    Sep 28 at 11:56
  • what parameters are included in gladLoadGL()? Tell me the literature on this topic
    – Mark Soir
    Sep 28 at 14:50
  • the code was taken from the website win-ni.narod.ru/FPC/winhello.htm
    – Mark Soir
    Sep 28 at 14:57
  • 1
    You should have linked to that right away. And that program alone also compiles. The compiler complains about the bits you put into it on your own, not understanding what parameters to procedures/functions are.
    – AmigoJack
    Sep 28 at 18:42
  • I've removed the Delphi tag. You're clearly not using Delphi, and you've set the compiler mode to {$mode objfpc}{$H+}, which means you're not compiling in Delphi mode. Please do not add tags that do not actually apply to your post, even if you think the additional attention might help. Tags have purpose and meaning here, and should not be misused.
    – Ken White
    Sep 29 at 4:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.