GuvaCode / ray4laz

A complete header translation (binding) of the raylib 5.0 to Pascal. Without any funky helper functions for memory alignment issues. Inspired and partially based on the drezgames/raylib-pascal binding, however a little cleaner and more recent, with FPC 3.2.0 and up support.
https://www.raylib.com/
zlib License
98 stars 18 forks source link

raylib window context to OpenGLControl (initial code) #19

Closed ghost closed 1 year ago

ghost commented 1 year ago

Still working on this, but the rendering happens in the TOpenGLControl on the form.

uses
OpenGLContext, raylib, glfw, Windows;
  TPortFrm = class(TForm)
    OpenGLControl1: TOpenGLControl;
    procedure FormCreate(Sender: TObject);
    procedure OpenGLControl1Paint(Sender: TObject);
  private
    WndContext: pGLFWwindow;
  public

  end;
procedure TPortFrm.FormCreate(Sender: TObject);
begin
  InitWindow(1600, 900, 'port');
  SetTargetFPS(60);
  WndContext:=glfwGetCurrentContext();
  OpenGLControl1.Handle:=HWND(WndContext);
end; 
procedure TPortFrm.OpenGLControl1Paint(Sender: TObject);
begin
  while not WindowShouldClose do begin
    BeginDrawing;
    ClearBackground(RED);
    OpenGLControl1.SwapBuffers;
    EndDrawing;
  end;
end; 
GuvaCode commented 1 year ago

wow. It's very interesting I'll do it today.

ghost commented 1 year ago

wow. It's very interesting I'll do it today.

thanks, appreciate it!

GuvaCode commented 1 year ago

well. I tried without glfw. I got the handle by means of raylib itself. but under gtk2 it all crashes. there is an idea to wrap it all in streams.

ghost commented 1 year ago

well. I tried without glfw. I got the handle by means of raylib itself. but under gtk2 it all crashes. there is an idea to wrap it all in streams.

i can test your implemenations on Windows, whenever you're ready

ghost commented 1 year ago

my previous OnPaint event led to freezing, so by removing the while loop, it allowed me to keep the form from freezing

procedure TPortFrm.OpenGLControl1Paint(Sender: TObject);
begin
    BeginDrawing;
    ClearBackground(RED);
    EndDrawing;
    OpenGLControl1.SwapBuffers;
end;  
ghost commented 1 year ago

DrawFPS seems to be causing a crash, testing 3D stuff next w/wo rlgl standalone methods

GuvaCode commented 1 year ago

Well, I don't understand what's going wrong. when swapbuffer crashes. gtk2 and qt5

GuvaCode commented 1 year ago

I was only able to call a separate window through a thread. But I've done this before https://github.com/GuvaCode/Ray4LazExample/tree/main/Visual_3d_Camera_in_LCL

ghost commented 1 year ago

I was only able to call a separate window through a thread. But I've done this before https://github.com/GuvaCode/Ray4LazExample/tree/main/Visual_3d_Camera_in_LCL

thanks, maybe your code will do the trick for me, since this looks like a black box. my wild guess is that the opengl state gets mixed up somewhere along the line

GuvaCode commented 1 year ago

and why do you need output on the lcl context? now I'm writing a binding for another engine.https://worldsim3d.forumotion.com/t7-worldsim3d-development-roadmap you can join

ghost commented 1 year ago

and why do you need output on the lcl context? now I'm writing a binding for another engine.https://worldsim3d.forumotion.com/t7-worldsim3d-development-roadmap you can join

mostly for the convienience of it and to see how it would work for now, i can check out the engine every now and again

GuvaCode commented 1 year ago

can I learn your native language?

GuvaCode commented 1 year ago

Финский ? Или латыш?

ghost commented 1 year ago

well, its finnish (see profile) so we're neighbouring countries :P unfortunately i can't speak russian

GuvaCode commented 1 year ago

"unfortunately i can't speak russian " bad. I was really hoping

ghost commented 1 year ago

"unfortunately i can't speak russian " bad. I was really hoping 😂