Tema: Opengl???
Ver Mensaje Individual
  #3  
Antiguo 13-07-2003
Avatar de marcoszorrilla
marcoszorrilla marcoszorrilla is offline
Capo
 
Registrado: may 2003
Ubicación: Cantabria - España
Posts: 11.221
Reputación: 10
marcoszorrilla Va por buen camino
Código:
function CreateRenderingContext(DC: HDC; Options: TRCOptions; ColorDepth: Integer; StencilBits: Byte): HGLRC;

// Set the OpenGL properties required to draw to the given canvas and
// create a rendering context for it.

var PFDescriptor : TPixelFormatDescriptor;
    PixelFormat  : Integer;

begin
  FillChar(PFDescriptor,SizeOf(PFDescriptor),0);
  with PFDescriptor do
  begin
    nSize:=sizeof(PFDescriptor);
    nVersion:=1;
    dwFlags:=PFD_SUPPORT_OPENGL;
    if GetObjectType(DC) in [OBJ_MEMDC,OBJ_METADC,OBJ_ENHMETADC]
      then dwFlags:=dwFlags or PFD_DRAW_TO_BITMAP
      else dwFlags:=dwFlags or PFD_DRAW_TO_WINDOW;
    if opDoubleBuffered in Options then dwFlags:=dwFlags or PFD_DOUBLEBUFFER;
    if opGDI in Options then dwFlags:=dwFlags or PFD_SUPPORT_GDI;
    if opStereo in Options then dwFlags:=dwFlags or PFD_STEREO;
    iPixelType:=PFD_TYPE_RGBA;
    cColorBits:=ColorDepth;
    cDepthBits:=32;
    cStencilBits:=StencilBits;
    iLayerType:=Byte(PFD_MAIN_PLANE);
  end;

  InitOpenGL; // just in case it didn't happen already
  PixelFormat:=ChoosePixelFormat(DC,@PFDescriptor);
  SetPixelFormat(DC,PixelFormat,@PFDescriptor);
  // check the properties just set
  DescribePixelFormat(DC,PixelFormat,SizeOf(PFDescriptor),@PFDescriptor);
  with PFDescriptor do
    if (dwFlags and PFD_NEED_PALETTE) <> 0 then SetupPalette(DC,PFDescriptor);

  Result:=wglCreateContext(DC);

  // read implementation properties
  if FirstContext and (Result > 0) then
  begin
    wglMakeCurrent(DC,Result);
    ReadImplementationProperties;
    FirstContext:=False;
    wglMakeCurrent(0,0);
  end;
end;
Si quieres bajarte la Unit completa la tienes en la DelphiSuperpage.

Un Saludo.

Última edición por marcoszorrilla fecha: 13-07-2003 a las 19:26:23.
Responder Con Cita