Lowercase
25-10-2006, 08:43 PM
I already posted a thread on sulaco website forum without reply ...
If you're using a c++ style template for delphi, there's a little bug (in my opinion) in the windowed mode.. (the one i use although, there is a large number of template on the web)
the viewport is not properly set because the height of the title bar is included.
as an example, if you use glreadpixels you can notice there's a black area in the window titlebar's place.
In the following code the parameters Width and Height are no longer used.(so they can be deleted)
It works for both windowed and fullscreen mode.
procedure glResizeWnd(Width, Height : Integer);
var
ClientRect : TRect;
ScreenHeight, ScreenWidth : integer
begin
GetClientRect(h_wnd,ClientRect);
ScreenHeight := ClientRect.bottom - ClientRect.Top;
ScreenWidth := ClientRect.Right - ClientRect.Left;
if (ScreenHeight = 0) then // prevent divide by zero exception
ScreenHeight := 1;
glViewport(0, 0, ScreenWidth, ScreenHeight); // Set the viewport for the OpenGL window
glMatrixMode(GL_PROJECTION); // Change Matrix Mode to Projection
glLoadIdentity(); // Reset View
gluPerspective(45.0, ScreenWidth/ScreenHeight, 1.0, 100.0); // Do the perspective calculations. Last value = max clipping depth
glMatrixMode(GL_MODELVIEW); // Return to the modelview matrix
glLoadIdentity(); // Reset View
end;
what do you think ?
If you're using a c++ style template for delphi, there's a little bug (in my opinion) in the windowed mode.. (the one i use although, there is a large number of template on the web)
the viewport is not properly set because the height of the title bar is included.
as an example, if you use glreadpixels you can notice there's a black area in the window titlebar's place.
In the following code the parameters Width and Height are no longer used.(so they can be deleted)
It works for both windowed and fullscreen mode.
procedure glResizeWnd(Width, Height : Integer);
var
ClientRect : TRect;
ScreenHeight, ScreenWidth : integer
begin
GetClientRect(h_wnd,ClientRect);
ScreenHeight := ClientRect.bottom - ClientRect.Top;
ScreenWidth := ClientRect.Right - ClientRect.Left;
if (ScreenHeight = 0) then // prevent divide by zero exception
ScreenHeight := 1;
glViewport(0, 0, ScreenWidth, ScreenHeight); // Set the viewport for the OpenGL window
glMatrixMode(GL_PROJECTION); // Change Matrix Mode to Projection
glLoadIdentity(); // Reset View
gluPerspective(45.0, ScreenWidth/ScreenHeight, 1.0, 100.0); // Do the perspective calculations. Last value = max clipping depth
glMatrixMode(GL_MODELVIEW); // Return to the modelview matrix
glLoadIdentity(); // Reset View
end;
what do you think ?