OpenGL - renderiza diretamente para bitmap
Eu estou fazendo aplicação que tem um monte de pequenas janelas e controles nele (por isso é renderização 2D), e gostaria de processar cada janela e controle para seu próprio bitmap (não há muito deles). Isto é o que tem:
uses dglOpenGL;
...
var BMP: TBitmap;
DC, RC: HDC;
...
function TMainForm.Init: Boolean;
begin
Result := InitOpenGL;
if Result = True then
begin
BMP := TBitmap.Create;
BMP.PixelFormat := pf24bit;
BMP.Width := 1280;
BMP.Height := 1024;
DC := (BMP.Canvas.Handle);
RC := CreateRenderingContext(DC,
[opGDI, opDoubleBuffered],//tried changing, didn't help
24,
24,
0,
0,
0,
0);
ActivateRenderingContext(DC, RC);
glClearColor(0.27, 0.4, 0.7, 0.0);//Light blue
glViewport(0, 0, 1280, 1024);
glMatrixMode(GL_PROJECTION);
glLoadIdentity;
glOrtho(0, 1280, 0, 1024, -1, 10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
end;
end;
Procedimento de renderização:
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
//Red quad
glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex2f(100, 100);
glVertex2f(1280-100, 100);
glVertex2f(1280-100, 1024-100);
glVertex2f(100, 1024-100);
glend;
//Output
SwapBuffers(DC);
Mas não há saída.
Se eu usarMainForm.Canvas.Draw(0, 0, BMP);
então o retângulo branco aparecerá.
Eu quero fazer material de renderização em bitmaps, porque eu posso fazer um monte de coisas com bitmaps (desenhar gráfico nele, pintar texto, blur), mas se há outra maneira de fazer renderização fora da tela, então está tudo bem ...
Então, como eu configuro meu aplicativo para renderização fora da tela?