|
|
#21 |
|
Пенсионер
|
Правильно сдается, но этот активчик, бесплатная примочка к IE насколько мне помнится...
__________________
Законы природы еще никто не отменял!А еще у меня растет 2 внучки!!! Кому интересно подробности тут: http://www.baby-shine.com/ |
|
|
|
|
#22 |
|
Участник
|
|
|
|
|
|
#23 |
|
MCTS
|
Очень странно, не удается установить формат пиксела, равный 5. Это значение выдает функция ChoosePixelFormat. С другой стороны, без проблем ставится значение 19, но для этого значения функция glClearColor() не отрабатывает.... Может быть нужно как то по другому передавать структуру? Если есть у кого какие соображения пожалуйста поделитесь... Вот код:
X++: static void Job2(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); // dwFlags pixelFormatDescriptor.byte(8, 0); // iPixelType pixelFormatDescriptor.byte(9, 24); // cColorBits pixelFormatDescriptor.byte(10, 0); // cRedBits; pixelFormatDescriptor.byte(11, 0); // cRedShift; pixelFormatDescriptor.byte(12, 0); // cGreenBits; pixelFormatDescriptor.byte(13, 0); // cGreenShift; pixelFormatDescriptor.byte(14, 0); // cBlueBits; pixelFormatDescriptor.byte(15, 0); // cBlueShift; pixelFormatDescriptor.byte(16, 0); // cAlphaBits; pixelFormatDescriptor.byte(17, 0); // cAlphaShift; pixelFormatDescriptor.byte(18, 0); // cAccumBits; pixelFormatDescriptor.byte(19, 0); // cAccumRedBits; pixelFormatDescriptor.byte(20, 0); // cAccumGreenBits; pixelFormatDescriptor.byte(21, 0); // cAccumBlueBits; pixelFormatDescriptor.byte(22, 0); // cAccumAlphaBits; pixelFormatDescriptor.byte(23, 32); // 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); } |
|
|
|
|
#24 |
|
Участник
|
Как же это будет работать, если Вы все запретили, OpenGL c ума сойдет. См. хелп по параметру cRedBits и за ним следующими.
Вот так отлично работает: X++: 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, 64); // nVersion
pixelFormatDescriptor.dWord(4, 8191); // dwFlags
pixelFormatDescriptor.byte(8, 0); // iPixelType
pixelFormatDescriptor.byte(9, 64); // cColorBits
pixelFormatDescriptor.byte(10, 64); // cRedBits;
pixelFormatDescriptor.byte(11, 64); // cRedShift;
pixelFormatDescriptor.byte(12, 64); // cGreenBits;
pixelFormatDescriptor.byte(13, 64); // cGreenShift;
pixelFormatDescriptor.byte(14, 64); // cBlueBits;
pixelFormatDescriptor.byte(15, 64); // cBlueShift;
pixelFormatDescriptor.byte(16, 64); // cAlphaBits;
pixelFormatDescriptor.byte(17, 64); // cAlphaShift;
pixelFormatDescriptor.byte(18, 64); // cAccumBits;
pixelFormatDescriptor.byte(19, 64); // cAccumRedBits;
pixelFormatDescriptor.byte(20, 64); // cAccumGreenBits;
pixelFormatDescriptor.byte(21, 64); // cAccumBlueBits;
pixelFormatDescriptor.byte(22, 64); // cAccumAlphaBits;
pixelFormatDescriptor.byte(23, 64); // cDepthBits;
pixelFormatDescriptor.byte(24, 64); // cStencilBits;
pixelFormatDescriptor.byte(25, 64); // cAuxBuffers;
pixelFormatDescriptor.byte(26, 0); // iLayerType;
pixelFormatDescriptor.byte(27, 64); // bReserved;
pixelFormatDescriptor.dWord(28, 64); // dwLayerMask;
pixelFormatDescriptor.dWord(32, 64); // dwVisibleMask;
pixelFormatDescriptor.dWord(36, 64); // 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); |
|
|
|
|
#25 |
|
Участник
|
Что значит отлично работает? Вы попробовали хоть фон-то почистить, что за 64 в строчках, откуда такая версия OpenGL?
|
|
|
|
|
#26 |
|
Участник
|
Вообще есть вот функция
X++: int DescribePixelFormat( HDC hdc, // device context of interest int iPixelFormat, // pixel format selector UINT nBytes, // size of buffer pointed to by ppfd LPPIXELFORMATDESCRIPTOR ppfd // pointer to structure to receive pixel // format data ); |
|
|
|
|
#27 |
|
Участник
|
Значит, что не выдает ошибок и устанавливает нормальный PixelFormat
Да, поставьте туда хоть 256, работать будет. Чтобы почистить фон одного SetPixelFormat мало. Еще бы SwapBuffers не помешал |
|
|
|
|
#28 |
|
Участник
|
Цитата:
Сообщение от Dronas
Вообще есть вот функция
X++: int DescribePixelFormat( HDC hdc, // device context of interest int iPixelFormat, // pixel format selector UINT nBytes, // size of buffer pointed to by ppfd LPPIXELFORMATDESCRIPTOR ppfd // pointer to structure to receive pixel // format data ); |
|
|
|
|
#29 |
|
Участник
|
Соврал, она работает нормально, вот резульат заполнения PFD
X++: cColorBits 32 cRedBits 8 cRedShift 16 cGreenBits 8 cGreenShift 8 cBlueBits 8 cBlueShift 0 cAlphaBits 0 cAlphaShift 0 cAccumBits 64 cAccumRedBits 16 cAccumGreenBits 16 cAccumBlueBits 16 cAccumAlphaBits 0 cDepthBits 16 cStencilBits 8 cAuxBuffers 0 iLayerType 0 bReserved 0 dwLayerMask 0 dwVisibleMask 0 dwDamageMask 0 |
|
|
|
|
#30 |
|
Участник
|
а в pixelFormatDescriptor.dWord(4, 8191); // dwFlags 37 должно быть.
|
|
|
|
|
#31 |
|
Участник
|
|
|
|
|
|
#32 |
|
Участник
|
Не обращайте внимание на значения, которые я указал они взяты с потолка. Просто разрешил все что можно, а в реальном проекте нужно выставлять только необходимые флаги. По-моему достаточно этих:
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA |
|
|
|
|
#33 |
|
Участник
|
прогресс
|
|
|
|
|
#34 |
|
Участник
|
Обычно такая картинка бывает из за неверно вызванного swapBuffer. OpenGL отрисовывает в буфер, находящейся в памяти, а потом SwapBuffer выводит на экран. SwapBuffer нужно вызывать при каждой перерисовке окна.
|
|
|
|
|
#35 |
|
Участник
|
Да у меня по порядку идёт инициализация, очистка и свап, видно, что буфер с ошибками, да и не тем цветом "очищается".
Ещё не понятно, почему лишь часть с окраской, по идее всё поле должно быть в такой мути. |
|
|
|
|
#36 |
|
Участник
|
Так бывает если не вызвать glClear. Когда учил OpenGL часто с этим сталкивался. Почему не весь экран в мути не знаю, но бывает именно так как на вашем рисунке. Возьмите любой пример на OpenGL и уберите glClear (или не вызовите SwapBuffers) получите именно это.
|
|
|
|
|
#37 |
|
Участник
|
ну есть оно у меня.Только там контекст потом не удаляется. Последний раз редактировалось Dronas; 27.11.2006 в 16:00. |
|
|
|
|
#38 |
|
MCTS
|
Слушайте, есть одна мысль, может быть, когда мы пишем glClear.call(16384);
на самом деле как этой функции так и другим передается не int, а что то другого размера... |
|
|
|
|
#39 |
|
MCTS
|
Насчет DescribePixelFormat как то берет сомнение, что она сможет эту чудо структуру Х++ заполнить
|
|
|
|
|
#40 |
|
Участник
|
Цитата:
Даже если и не сможет, можно обойтись и без нее. Тем не менее выложенный проект у меня выдает GetLastError = 2000 (Invalid PixelFormat). Наверное все таки как-то не так передается эта структура в функцию SetPixelFormat, хотя что не так непонятно. Все тоже самое на C++ работает. |
|
|