OpenGLContext questions. lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- Wodzu · 2010-04-03 12:45 I was testing the OpenGLContext component. It looks promising but I have two qeustions: 1. Where is the best place to initialize OpenGL and it's structures? For example, I need to create some display list. I can not do it here: Code: [Select]procedure TForm1.FormCreate(Sender: TObject); begin   if Sender=nil then ;   OpenGLControl1:=TOpenGLControl.Create(Self);   with OpenGLControl1 do begin     Name:='OpenGLControl1';     Align:=alClient;     Parent:=Self;     OnPaint:=@OpenGLControl1Paint;     OnResize:=@OpenGLControl1Resize;     AutoResizeViewport:=true;   end;     MyListIndex := glGenLists(10); //this wont work   Application.AddOnIdleHandler(@OnAppIdle);    end; Could someone explain to me why glGenList(); will not work in the onCreate event? onCreate should be executed after window has been created, right? But glGenLists(); is not returning the first created index lists. Now I am initializing my data structures in first(and only first) onActivate event, but this is not very convenient. 2. How to do full screen with this component? Thanks in advance. ---------------------------------------------------------------------- Leledumbo · 2010-04-05 12:27 QuoteWhere is the best place to initialize OpenGL and it's structures?OnCreate of the form (you already did it right). It's just... why did you create it by code? It's better to drop the component on the form. QuoteCould someone explain to me why glGenList(); will not work in the onCreate event?Not sure. To my knowledge, OpenGL has its own data structure management that has nothing to do with the surface where its drawn. Maybe you could query the error to OpenGL (use glGetError). QuoteHow to do full screen with this component?AFAIK, LCL doesn't yet support full screen. GLScene implements it with its TGLFullScreenViewer. ---------------------------------------------------------------------- Wodzu · 2010-04-05 12:45 Thank you for your anser. QuoteOnCreate of the form (you already did it right). It's just... why did you create it by code? It's better to drop the component on the form. Because that how it was shown on the example code QuoteCould someone explain to me why glGenList(); will not work in the onCreate event?Not sure. To my knowledge, OpenGL has its own data structure management that has nothing to do with the surface where its drawn. Maybe you could query the error to OpenGL (use glGetError). [/quote] I think that the problem is that the OpenGl context is not ready in the OnCreate() event. Because glGenLists();  is working in OnActivate event. QuoteAFAIK, LCL doesn't yet support full screen. GLScene implements it with its TGLFullScreenViewer. What a shame:( I am starting to losing a hope for small compact solution for OpenGL application... ---------------------------------------------------------------------- PeteS · 2010-04-05 18:49 I call a routine to build a scene using glGenLists() from the OnShow event.  Works fine for me, so you are probably correct that the OpenGL context is not ready. For full screen I set the form WindowState to wsMaximized and the BorderStyle to bsNone, with the OpenGL context aligned as alClient.  Works for me.  I also disable theme support under Windows (due to flicking) - this is a reported bug that I'm sure will be fixed. Hope this helps. ---------------------------------------------------------------------- Wodzu · 2010-04-05 19:09 Thanks PeteS, I'll try that. There is one thing which is worrying me. Have you noticed a performance drop when you make your window larger? This is noticable even with a rotated cube, If I resize window from 640x480 to some larger size cube is rotating like 15 FPS. How to fix that? I have Dell laptop with GeForce 8800 so rotated cube should be displayed with fluent animation on all resolutions, I think. Maybe I need to increase my main thread priority? ---------------------------------------------------------------------- Leledumbo · 2010-04-06 02:02 QuoteHow to fix that?Use double buffering (set OpenGLContext.DoubleBuffered := true and call SwapBuffers in the end of paint). Single buffering is slllooowww... ---------------------------------------------------------------------- Wodzu · 2010-04-06 05:33 Quote from: Leledumbo on April 06, 2010, 04:02:05 amQuoteHow to fix that?Use double buffering (set OpenGLContext.DoubleBuffered := true and call SwapBuffers in the end of paint). Single buffering is slllooowww... Thanks, I am using that. But that doesn't help. Perfromance is very bad. But I do not think this is the problem of OpenGLContext. I have the same slow perfromance when I am not using OpenGLContext. Everything is very quick on small resolution but when I make it bigger it is very very slow. I've tested it under 3 different machines. On my laptop this is the most noticable. On stationary machine with some crappy Intel card it works faster. On other laptop it also works faster. However on all three machines the performance is dropping after making window larger. ---------------------------------------------------------------------- PeteS · 2010-04-11 08:13 Never had those sort of speed problems, and I'm using a really old 256MB GeForce FX5500.  Try the system graphics settings; maybe you have a lot of anti-aliasing settings on? ---------------------------------------------------------------------- Wodzu · 2010-04-11 09:21 The graphics card itself is not a problem. Even the games from 2009/2010 are working nicely. Hmm I've tested it today and it is working fluently. Maybe I had in previous tests some additional processes running in background. Thanks for the responsesand sorry for the hussle. ---------------------------------------------------------------------- User137 · 2010-04-11 09:39 I have another question about OpenGLContext. So far it has been working fine under Win32 and i'm even able to use dglOpenGL headers with it. But i don't need the actual visual component for IDE because i create it via my graphics engine class, so annoyance comes when i have to add package LazOpenGLContext to every project using it. I'm almost fine with it however this didn't work for Linux. Series of compiler errors etc etc, cannot "make build all" or what the command was, completely destroyed Lazarus from my Linux (Ubuntu 9.10) partition. But i would have none of the above problems if i would include OpenGLContext source within my graphics library. Is this "allowed" way to do it and is it even possible? I haven't looked up on packages before. I had to move from Windows API based context creation so it had better chance for portability.