Показать сообщение отдельно
Старый 28.11.2006, 17:51   #57  
Eldar9x is offline
Eldar9x
MCTS
Аватар для Eldar9x
Oracle
MCBMSS
 
1,064 / 166 (8) ++++++
Регистрация: 29.09.2006
Адрес: Казань
Вот код - никакой ругани, никаких результатов его выполнения ))
X++:
static void Lacky13(Args _args)
{
  HWND mainWindow;
    int dc;
    HWND hrc;
    int  nPixelFormat;
    // Загрузка библиотек
    DLL  opengl32 = new DLL("opengl32.dll");
    DLL  glu32    = new DLL("glu32.dll");
    DLL  gdi32    = new DLL("gdi32.dll");
    DLL  user32   = new DLL("user32");
    //
    COMVariant parm5 = new COMVariant();
    // Получение точек входа функций
    DLLFunction wglCreateContext  = new DLLFunction(opengl32, "wglCreateContext");
    DLLFunction wglMakeCurrent    = new DLLFunction(opengl32, "wglMakeCurrent");
    DLLFunction glEnable          = new DLLFunction(opengl32, "glEnable");
    DLLFunction ChoosePixelFormat = new DLLFunction(gdi32,    "ChoosePixelFormat");
    DLLFunction SetPixelFormat    = new DLLFunction(gdi32,    "SetPixelFormat");
    DLLFunction glMatrixMode      = new DLLFunction(opengl32, "glMatrixMode");
    DLLFunction glLoadIdentity    = new DLLFunction(opengl32, "glLoadIdentity");
    DLLFunction gluPerspective    = new DLLFunction(glu32,    "gluPerspective");
    DLLFunction glClearColor      = new DLLFunction(opengl32, "glClearColor");
        COMVariant parm1 = new COMVariant();
        COMVariant parm2 = new COMVariant();
        COMVariant parm3 = new COMVariant();
        COMVariant parm4 = new COMVariant();
    DLLFunction getWindowDC       = new DLLFunction(user32, "GetWindowDC");
    DLLFunction glClear           = new DLLFunction(opengl32, "glClear");
    //
    Binary  pixelFormatDescriptor;
    //
    boolean fInfo = false;
    void initializeRC()
    {
        glEnable.call(2929);
        glEnable.call(2896);
        glEnable.call(16384);
    }
    ;
    // Установка функций
    wglCreateContext.returns(ExtTypes::DWord);
    wglCreateContext.arg(ExtTypes::DWord);
    wglMakeCurrent.returns(ExtTypes::DWord);
    wglMakeCurrent.arg(ExtTypes::DWord, ExtTypes::DWord);
    glEnable.returns(ExtTypes::void);
    glEnable.arg(ExtTypes::DWord);
    ChoosePixelFormat.returns(ExtTypes::DWord);
    ChoosePixelFormat.arg(ExtTypes::DWord, ExtTypes::Pointer);
    SetPixelFormat.returns(ExtTypes::DWord);
    SetPixelFormat.arg(ExtTypes::DWord, ExtTypes::DWord, ExtTypes::Pointer);
    glMatrixMode.returns(ExtTypes::void);
    glMatrixMode.arg(ExtTypes::DWord);
    glLoadIdentity.returns(ExtTypes::void);
    glLoadIdentity.arg();       // возможно нужно добавить
    gluPerspective.returns(ExtTypes::void);
    gluPerspective.arg(ExtTypes::Double, ExtTypes::Double, ExtTypes::Double, ExtTypes::Double);
    glClearColor.returns(ExtTypes::void);
    glClearColor.arg(ExtTypes::DWord, ExtTypes::DWord, ExtTypes::DWord, ExtTypes::DWord);
    parm1.float(1.0);
    parm2.float(0.0);
    parm3.float(0.0);
    parm4.float(1.0);
    getWindowDC.returns(ExtTypes::DWORD);
    getWindowDC.arg(ExtTypes::DWORD);
    glClear.returns(ExtTypes::void);
    glClear.arg(ExtTypes::DWord);
    //
    mainWindow = infolog.hWnd();
    //parm5.int(mainWindow);
    dc  = getWindowDC.call(mainWindow);
   // dc = WinApi::createDC();
    // Формат пиксела
        pixelFormatDescriptor = new Binary(40);
        pixelFormatDescriptor.Word(0, 40);                // nSize
        pixelFormatDescriptor.Word(2, 1);                 // nVersion
        pixelFormatDescriptor.dWord(4, 4|32|1);//8191);     // dwFlags
        pixelFormatDescriptor.byte(8, 0);                 // iPixelType
        pixelFormatDescriptor.byte(9, 32);                // cColorBits
        pixelFormatDescriptor.byte(10, 8);  // cRedBits;
        pixelFormatDescriptor.byte(11, 8);  // cRedShift;
        pixelFormatDescriptor.byte(12, 8);  // cGreenBits;
        pixelFormatDescriptor.byte(13, 0);  // cGreenShift;
        pixelFormatDescriptor.byte(14, 0);  // cBlueBits;
        pixelFormatDescriptor.byte(15, 0);  // cBlueShift;
        pixelFormatDescriptor.byte(16, 64);  // cAlphaBits;
        pixelFormatDescriptor.byte(17, 16);  // cAlphaShift;
        pixelFormatDescriptor.byte(18, 16);  // cAccumBits;
        pixelFormatDescriptor.byte(19, 16);  // cAccumRedBits;
        pixelFormatDescriptor.byte(20, 0);  // cAccumGreenBits;
        pixelFormatDescriptor.byte(21, 16);  // cAccumBlueBits;
        pixelFormatDescriptor.byte(22, 8);  // cAccumAlphaBits;
        pixelFormatDescriptor.byte(23, 0); // cDepthBits;
        pixelFormatDescriptor.byte(24, 0);  // cStencilBits;
        pixelFormatDescriptor.byte(25, 0);  // cAuxBuffers;
        pixelFormatDescriptor.byte(26, 0);  // iLayerType;
        pixelFormatDescriptor.byte(27, 0);  // bReserved;
        pixelFormatDescriptor.dWord(28, 0); // dwLayerMask;
        pixelFormatDescriptor.dWord(32, 0); // dwVisibleMask;
        pixelFormatDescriptor.dWord(36, 0); // dwDamageMask
        nPixelFormat = ChoosePixelFormat.call(dc, pixelFormatDescriptor);
    if (SetPixelFormat.call(dc, nPixelFormat, pixelFormatDescriptor)==0) info( "SetPixelFormat function failed.");
    hrc = wglCreateContext.call(dc);
    if (!hrc)   info( "wglCreateContext function failed.");
    if(!wglMakeCurrent.call(dc, hrc))   info( "wglMakeCurrent function failed.");
    //initializeRC();
    glClearColor.call(parm1.int(), parm2.int(), parm3.int(), parm4.int());
    glClear.call(16384);
   // opengl32_glMatrixMode.call(5889);
    //opengl32_glLoadIdentity.call();
   // glu32_gluPerspective.call(10.0, 1.0, 1.0, 10.0);

    if (fInfo)
    {
    info(mainWindow?"mainWindow = OK":"mainWindow = Error");
    info(dc?"dc = OK":"dc = Error");
    info(opengl32?"openGL = OK": "opengL = Error");
    info(glu32?"glu32 = OK": "glu32 = Error");
    info(gdi32?"gdi32 = OK": "gdi32 = Error");
    info(wglCreateContext?"wglCreateContext = OK":"wglCreateContext = ERROR");
    info(wglMakeCurrent?"wglMakeCurrent = OK": "wglMakeCurrent = ERROR");
    info(glEnable?"glEnable = OK": "glEnable = ERROR");
    info(ChoosePixelFormat?"ChoosePixelFormat = OK":"ChoosePixelFormat = OK");
    info(SetPixelFormat?"SetPixelFormat = OK":"SetPixelFormat = ERROR");
    info(glMatrixMode?"glMatrixMode = OK":"glMatrixMode = ERROR");
    info(gluPerspective?"gluPerspective = OK":"gluPerspective = ERROR");
    info(glClearColor?"glClearColor = OK":"glClearColor = ERROR");
    }
    // устанавливаем формат пиксела
   // wglMakeCurrent.call(0, 0);
   // WinAPI::releaseDC(mainWindow, dc);
}