Path: ddt.demos.su!not-for-mail
From: "Mike \"CybeRUS\" Samsonov" <mike@bsu.ru>
Newsgroups: fido7.ru.opengl
Subject: Re: OpenGL окошко (контекст) в диалоге. Подскажите пожалуйста.
Date: 7 Mar 2000 09:18:46 +0300
Organization: JSC Electrosvyaz, Republic Buryatia
Lines: 120
Sender: fido7@ddt.demos.su
Approved: <gateway@fido7.ru>
Message-ID: <952409874.133349@ns.burnet.ru>
References: <89s6eu$u39$1@nova.psn.ru>
NNTP-Posting-Host: ddt.demos.su
X-Trace: ddt.demos.su 952409927 899 194.87.13.37 (7 Mar 2000 06:18:47 GMT)
X-Complaints-To: gatekeeper@fido7.ru
NNTP-Posting-Date: 7 Mar 2000 06:18:47 GMT
X-BeforeModerator-Path: not-for-mail
X-BeforeModerator-NNTP-Posting-Host: ns.burnet.ru
X-BeforeModerator-X-Trace: bison.rosnet.ru 952409796 8912 212.0.65.2 (7 Mar 2000 06:16:36 GMT)
X-BeforeModerator-X-Complaints-To: news-abuse@rosnet.net
X-BeforeModerator-NNTP-Posting-Date: 7 Mar 2000 06:16:36 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6700
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700
Cache-Post-Path: ns.burnet.ru!unknown@mike.bsu.ru
X-Cache: nntpcache 2.3.2.1 (see http://www.nntpcache.org/)
Xref: ddt.demos.su fido7.ru.opengl:976


"Filippov Serge V." <fsv@impb.psn.ru> wrote in message
news:89s6eu$u39$1@nova.psn.ru...
> Привет, All !
>
>    Подскажите пожалуйста, если кто знает, как  сделать subj под Win32.
> Конкретно, нужно сделать preview материалов в диалоге выбора
> параметров этих самых материалов (как у редактора материалов в
> 3DS MAX). Простыми методами чего-то не получается. Добрые люди
> посоветовали ссылочку (там используется нечто похожее, но в диалоговом
> окне нет элементов управления). А самая большая проблема в том что
> там MFC, а я последнюю совсем не знаю (да и C++ тоже не очень).
> В общем, если кто знает как это сделать на C, напишите пожалуйста
> (лучше мылом  mailto:fsv@impb.psn.ru )

  Тебе можно сделать Render_To_Bitmap, а потом в Bitmap выводить на экран,
но это медленее.
  Вот стантардный исходник:
  procedure TForm2.RenderIntoBitmap(ABitmap: TBitmap);
var
  DC: HDC;
  RC: HGLRC;
  Aspect: GLFloat;
  Quadric: PGLUQuadricObj;

  procedure CreateRC;
  var
//    PFD, MatchPFD: TPixelFormatDescriptor;
    PFD: TPixelFormatDescriptor;
    PFI: Integer; { PixelFormatIndex }
    NewRC: HGLRC;
  begin
    FillChar(PFD, SizeOf(PFD), 0);
    with PFD do
    begin
      nSize      := SizeOf(PFD);                  // Size of this structure
      nVersion   := 1;                            // Version of this
structure
      dwFlags    := PFD_SUPPORT_OPENGL;           // Support OpenGL calls
      dwFlags    := dwFlags or PFD_DRAW_TO_BITMAP; // Draw into a bitmap
      iPixelType := PFD_TYPE_RGBA;                // RGBA color mode
      cColorBits := 24;
      cDepthBits := 24;                           // Size of depth buffer
      iLayerType := PFD_MAIN_PLANE;               // Draw in main plane
    end;
    PFI := ChoosePixelFormat(DC, @PFD);
    SetPixelFormat(DC, PFI, @PFD);
    NewRC := wglCreateContext(DC);
    if NewRC = 0 then
      raise Exception.Create('Invalid rendering context value');
    RC := NewRC;
  end;

begin
  DC := ABitmap.Canvas.Handle;
  CreateRC;
  try
    wglMakeCurrent(DC, RC);
    { === do your OpenGL stuff here === }
    Quadric := gluNewQuadric();
    try
      if ABitmap.Width = 0 then
        raise Exception.Create('Bitmap width and height must be > 0');
      Aspect := ABitmap.Width / ABitmap.Height;
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity;
      gluPerspective(30.0,           // Field-of-view angle
                     Aspect,         // Aspect ratio of viewing volume
                     0.5,            // Distance to near clipping plane
                     100);          // Distance to far clipping plane
      glViewport(0, 0, ABitmap.Width, ABitmap.Height);

      glClearColor(0, 0, 0, 0);
      glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
      glColor3f(1.0, 0.0, 0.0);
      gluQuadricDrawStyle(Quadric, GLU_SILHOUETTE);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity;

      gluLookAt(10, 0, 1.5, 0, 0, 1.5, 0, 1, 0);
      glPushMatrix;
      { now rotate local coordinate axis }
      glRotatef(Angle, 0, 0, 1);
      glColor3f(1.0, 0.0, 0.0);
      gluCylinder(Quadric, 0.5, 0.5, 3, 20, 20);
      glPopMatrix;
      { draw second cylinder at angle to first }
      glTranslatef(0, 0, -0.5);
      glRotatef(135, 0, 1, 0);
      { now rotate local coordinate axis }
      glRotatef(Angle, 0, 0, 1);
      glColor3f(0.0, 0.0, 1.0);
      { draw cylinder at local coordinate axis origin;
        gluCylinder will draw the base at 0,0,0 and the
        top at 0,0,+height
      }
      gluCylinder(Quadric, 0.5, 0.5, 3, 20, 20);
    finally
      gluDeleteQuadric(Quadric);
    end;
    { === end of your specified OpenGL stuff === }
  finally
    wglMakeCurrent(DC, 0);
    wglDeleteContext(RC);
  end;
end;

Есть другой
Можно создать Контекс на форме, а потом с помощью glViewport(0, 0,
ClientWidth, ClientHeight - 32);
(Это я делал чтобы сверху было место для кнопок)



>
> Заранее благодарен, FSV.
>
>


