|
![]() |
#1 |
MCTS
|
Вот код - никакой ругани, никаких результатов его выполнения
![]() 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); } |
|
![]() |
#2 |
MCTS
|
да, никак не успеваю оболочку для swapbuffer написать, скиньте, пожалуйста здесь
|
|
![]() |
#3 |
Участник
|
|
|
![]() |
#4 |
MCTS
|
О спасибо
![]() |
|
![]() |
#5 |
Участник
|
Вот, кое что подправил, ошибки должны в инфо выводиться, в инфо чисто, окно чёрное!
Lucky, твоя прога перезапустила винду при повторной попытке запуска ![]() Последний раз редактировалось Dronas; 29.11.2006 в 12:55. |
|
![]() |
#6 |
Участник
|
Цитата:
Опытным путем установлено: 1. Приложение на С выводит в главное окно Ax 2. Приложение на С выводит в окно главного меню Ax, но картинку видно только при закрытии окна (видимо Axapta затирает) 3. Приложение на С НЕ выводит в окно созданное пользователем. Что бы это могло значить? Вывод в компонент типа Window не проверял. |
|
![]() |
#7 |
Участник
|
|
|
![]() |
#8 |
Участник
|
Вывод есть, проверено, мне кажется у меня беда всё же с ClearColor
Запусти формочку из моего проекта. |
|
![]() |
#9 |
Участник
|
|
|
![]() |
#10 |
Участник
|
А это?
Есть одна засада, не плохо бы перезапустить машину после экспериментов с OpenGL. |
|
![]() |
#11 |
Участник
|
в
OpenGL_Initialize X++: ... //g_hWnd = Frame.hWnd(); g_hWnd = WinApi::findWindow("AxaptaClientClassName", ""); g_hWnd = WinApi::findWindowEx(g_hWnd, 0, "", ""); ... ![]() |
|
![]() |
#12 |
Участник
|
Цитата:
![]() А нарисовать что-нибудь получается или хотя бы в зеленый цвет покрасить. |
|
![]() |
#13 |
Участник
|
Во-во, контекст правильно не удалён, поэтому заново и не создаётся.
Цитата:
![]() Последний раз редактировалось Dronas; 29.11.2006 в 14:39. |
|
![]() |
#14 |
Участник
|
УРА, ЗАРАБОТАЛА!!!
Работает, но вот этот цирк мне не понятен
![]() X++: static int glClearColor(real red, real green, real blue, real alpha) { DLL _winApiDLL = new DLL("OPENGL32.dll"); DLLFunction _glClearColor = new DLLFunction(_winApiDLL, 'glClearColor'); COMVariant r = new COMVariant(); COMVariant g = new COMVariant(); COMVariant b = new COMVariant(); COMVariant a = new COMVariant(); r.float(red); g.float(green); b.float(blue); a.float(alpha); _glClearColor.returns(ExtTypes::void); _glClearColor.arg(ExtTypes::DWord, ExtTypes::DWord, ExtTypes::DWord, ExtTypes::DWord); return _glClearColor.call(r.int(), g.int(), b.int(), a.int()); } |
|
![]() |
#15 |
Участник
|
Вот так как было по-моему неправильно.
X++: _glClearColor.call(r.float(red), g.float(green), b.float(blue), a.float(alpha)); X++: return _glClearColor.call(r.int(), g.int(), b.int(), a.int()); |
|
![]() |
#16 |
Участник
|
Если float, то не будет, с интом вроде ничё.
|
|
![]() |
#17 |
Участник
|
Здесь советуют писать int, да будет так. Пусть это будет фича аксапты.
|
|
![]() |
#18 |
Участник
|
Теперь встал вопрос, что на ней делать?
![]() |
|
![]() |
#19 |
Участник
|
Оттеда и слямзено
![]() |
|
![]() |
#20 |
Участник
|
Всё, ужо и треугольники рисуются
![]() Интересно, шейдеры . . . |
|