Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raylib window context to OpenGLControl (initial code) #19

Closed
ghost opened this issue Jan 21, 2023 · 16 comments
Closed

raylib window context to OpenGLControl (initial code) #19

ghost opened this issue Jan 21, 2023 · 16 comments

Comments

@ghost
Copy link

ghost commented Jan 21, 2023

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
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Jan 22, 2023

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

thanks, appreciate it!

@GuvaCode
Copy link
Owner

GuvaCode commented Jan 22, 2023

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
Copy link
Author

ghost commented Jan 22, 2023

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
Copy link
Author

ghost commented Jan 22, 2023

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
Copy link
Author

ghost commented Jan 22, 2023

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

@GuvaCode
Copy link
Owner

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

@GuvaCode
Copy link
Owner

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
Copy link
Author

ghost commented Jan 22, 2023

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
Copy link
Owner

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
Copy link
Author

ghost commented Jan 22, 2023

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
Copy link
Owner

can I learn your native language?

@GuvaCode
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Jan 22, 2023

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

@GuvaCode
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Jan 22, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant