Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.10.14;
Скачать: [xml.tar.bz2];

Вниз

Беда...   Найти похожие ветки 

 
Xtreme   (2002-10-05 22:53) [0]

Люди! Писал программу... С использованием OpenGL"а... Окна создавал в ручную, без использования форм... Если компилить по Ctrl+F9, а потом запускать(например: из DISCo Commander"а), то все O"k. А если запускать по F9, то, с вероятностью примерно 75%, пишет: "Программа DDHELP выполнила недопустимую операцию и будет закрыта...". Короче, проблема с запуском программ из под делфи. Надавно, другая моя прога, подобного рода, стала также "глючить": жму F9, и выскакивает сообщение "Программа DDHELP выполнила...".

Что делать? Зачем нужен DDHELP? Где руки выпрямить?

P.S.
Delphi - 6.0 with Service Pack 1
Windows - 98 Second Edition


 
Николай Быков   (2002-10-06 08:20) [1]

ТЫ как эти формы создаешь?


 
Xtreme   (2002-10-06 09:45) [2]

Вот так(в сокращении):

function WndProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
case (Msg) of
WM_CREATE:
begin

end;
WM_CLOSE:
begin
PostQuitMessage(0);
Result := 0
end;
WM_KEYDOWN:
begin
Result := 0;
end;
WM_KEYUP:
begin
Result := 0;
end;
WM_SIZE:
begin
glResizeWnd(LOWORD(lParam),HIWORD(lParam));
Result := 0;
end;
WM_TIMER :
begin
if wParam = FPS_TIMER then
begin
FPSCount :=Round(FPSCount * 1000/FPS_INTERVAL);
SetWindowText(h_Wnd, PChar(WND_TITLE + " [" + intToStr(FPSCount) + " FPS]"));
FPSCount := 0;
Result := 0;
end;
end;
else
Result := DefWindowProc(hWnd, Msg, wParam, lParam);
end;
end;


 
Xtreme   (2002-10-06 09:46) [3]

procedure glKillWnd(Fullscreen : Boolean);
begin
if Fullscreen then // Change back to non fullscreen
begin
ChangeDisplaySettings(devmode(nil^), 0);
ShowCursor(True);
end;

// Makes current rendering context not current, and releases the device
// context that is used by the rendering context.
if (not wglMakeCurrent(h_DC, 0)) then
MessageBox(0, "Release of DC and RC failed!", "Error", MB_OK or MB_ICONERROR);

// Attempts to delete the rendering context
if (not wglDeleteContext(h_RC)) then
begin
MessageBox(0, "Release of rendering context failed!", "Error", MB_OK or MB_ICONERROR);
h_RC := 0;
end;

// Attemps to release the device context
if ((h_DC > 0) and (ReleaseDC(h_Wnd, h_DC) = 0)) then
begin
MessageBox(0, "Release of device context failed!", "Error", MB_OK or MB_ICONERROR);
h_DC := 0;
end;

// Attempts to destroy the window
if ((h_Wnd <> 0) and (not DestroyWindow(h_Wnd))) then
begin
MessageBox(0, "Unable to destroy window!", "Error", MB_OK or MB_ICONERROR);
h_Wnd := 0;
end;

// Attempts to unregister the window class
if (not UnRegisterClass("OpenGL", hInstance)) then
begin
MessageBox(0, "Unable to unregister window class!", "Error", MB_OK or MB_ICONERROR);
hInstance := 0;
end;
end;


 
Xtreme   (2002-10-06 09:49) [4]

function glCreateWnd(Width, Height : Integer; Fullscreen : Boolean; PixelDepth : Integer) : Boolean;
var
wndClass : TWndClass;
dwStyle : DWORD;
dwExStyle : DWORD;
dmScreenSettings : DEVMODE;
PixelFormat : GLuint;
h_Instance : HINST;
pfd : TPIXELFORMATDESCRIPTOR;
begin
h_Instance := GetModuleHandle(nil); //Grab An Instance For Our Window
ZeroMemory(@wndClass, SizeOf(wndClass)); // Clear the window class structure

with wndClass do // Set up the window class
begin
style := CS_HREDRAW or // Redraws entire window if length changes
CS_VREDRAW or // Redraws entire window if height changes
CS_OWNDC; // Unique device context for the window
lpfnWndProc := @WndProc; // Set the window procedure to our func WndProc
hInstance := h_Instance;
hCursor := LoadCursor(0, IDC_ARROW);
lpszClassName := "OpenGL";
end;

if (RegisterClass(wndClass) = 0) then // Attemp to register the window class
begin
MessageBox(0, "Failed to register the window class!", "Error", MB_OK or MB_ICONERROR);
Result := False;
Exit
end;

// Change to fullscreen if so desired
if Fullscreen then
begin
ZeroMemory(@dmScreenSettings, SizeOf(dmScreenSettings));
with dmScreenSettings do begin // Set parameters for the screen setting
dmSize := SizeOf(dmScreenSettings);
dmPelsWidth := Width; // Window width
dmPelsHeight := Height; // Window height
dmBitsPerPel := PixelDepth; // Window color depth
dmFields := DM_PELSWIDTH or DM_PELSHEIGHT or DM_BITSPERPEL;
end;




 
Xtreme   (2002-10-06 09:50) [5]

if (ChangeDisplaySettings(dmScreenSettings, CDS_FULLSCREEN) = DISP_CHANGE_FAILED) then
begin
MessageBox(0, "Unable to switch to fullscreen!", "Error", MB_OK or MB_ICONERROR);
Fullscreen := False;
end;
end;

if (Fullscreen) then
begin
dwStyle := WS_POPUP or // Creates a popup window
WS_CLIPCHILDREN // Doesn"t draw within child windows
or WS_CLIPSIBLINGS; // Doesn"t draw within sibling windows
dwExStyle := WS_EX_APPWINDOW; // Top level window
ShowCursor(False); // Turn of the cursor (gets in the way)
end
else
begin
dwStyle := WS_OVERLAPPEDWINDOW or // Creates an overlapping window
WS_CLIPCHILDREN or // Doesn"t draw within child windows
WS_CLIPSIBLINGS; // Doesn"t draw within sibling windows
dwExStyle := WS_EX_APPWINDOW or // Top level window
WS_EX_WINDOWEDGE; // Border with a raised edge
ShowCursor(False); // Turn of the cursor (gets in the way)
end;

h_Wnd := CreateWindowEx(dwExStyle, // Extended window styles
"OpenGL", // Class name
WND_TITLE, // Window title (caption)
dwStyle, // Window styles
0, 0, // Window position
Width, Height, // Size of window
0, // No parent window
0, // No menu
h_Instance, // Instance
nil); // Pass nothing to WM_CREATE
if h_Wnd = 0 then
begin
glKillWnd(Fullscreen); // Undo all the settings we"ve changed
MessageBox(0, "Unable to create window!", "Error", MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;

h_DC := GetDC(h_Wnd);
if (h_DC = 0) then
begin
glKillWnd(Fullscreen);
MessageBox(0, "Unable to get a device context!", "Error", MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;



 
Xtreme   (2002-10-06 09:50) [6]

with pfd do
begin
nSize := SizeOf(TPIXELFORMATDESCRIPTOR); // Size Of This Pixel Format Descriptor
nVersion := 1; // The version of this data structure
dwFlags := PFD_DRAW_TO_WINDOW // Buffer supports drawing to window
or PFD_SUPPORT_OPENGL // Buffer supports OpenGL drawing
or PFD_DOUBLEBUFFER; // Supports double buffering
iPixelType := PFD_TYPE_RGBA; // RGBA color format
cColorBits := PixelDepth; // OpenGL color depth
cRedBits := 0; // Number of red bitplanes
cRedShift := 0; // Shift count for red bitplanes
cGreenBits := 0; // Number of green bitplanes
cGreenShift := 0; // Shift count for green bitplanes
cBlueBits := 0; // Number of blue bitplanes
cBlueShift := 0; // Shift count for blue bitplanes
cAlphaBits := 0; // Not supported
cAlphaShift := 0; // Not supported
cAccumBits := 0; // No accumulation buffer
cAccumRedBits := 0; // Number of red bits in a-buffer
cAccumGreenBits := 0; // Number of green bits in a-buffer
cAccumBlueBits := 0; // Number of blue bits in a-buffer
cAccumAlphaBits := 0; // Number of alpha bits in a-buffer
cDepthBits := 16; // Specifies the depth of the depth buffer
cStencilBits := 0; // Turn off stencil buffer
cAuxBuffers := 0; // Not supported
iLayerType := PFD_MAIN_PLANE; // Ignored
bReserved := 0; // Number of overlay and underlay planes
dwLayerMask := 0; // Ignored
dwVisibleMask := 0; // Transparent color of underlay plane
dwDamageMask := 0; // Ignored
end;

PixelFormat := ChoosePixelFormat(h_DC, @pfd);
if (PixelFormat = 0) then
begin
glKillWnd(Fullscreen);
MessageBox(0, "Unable to find a suitable pixel format", "Error", MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;

if (not SetPixelFormat(h_DC, PixelFormat, @pfd)) then
begin
glKillWnd(Fullscreen);
MessageBox(0, "Unable to set the pixel format", "Error", MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;

h_RC := wglCreateContext(h_DC);
if (h_RC = 0) then
begin
glKillWnd(Fullscreen);
MessageBox(0, "Unable to create an OpenGL rendering context", "Error", MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;

if (not wglMakeCurrent(h_DC, h_RC)) then
begin
glKillWnd(Fullscreen);
MessageBox(0, "Unable to activate OpenGL rendering context", "Error", MB_OK or MB_ICONERROR);
Result := False;
Exit;
end;

SetTimer(h_Wnd, FPS_TIMER, FPS_INTERVAL, nil);

ShowWindow(h_Wnd, SW_SHOW);
SetForegroundWindow(h_Wnd);
SetFocus(h_Wnd);

glResizeWnd(Width, Height);
glInit();

Result := True;
end;


 
Xtreme   (2002-10-06 09:51) [7]

function WinMain(hInstance : HINST; hPrevInstance : HINST;
lpCmdLine : PChar; nCmdShow : Integer) : Integer; stdcall;
var
msg : TMsg;
begin
finished := False;

// Perform application initialization:
if not glCreateWnd(800, 600, false, 32) then
begin
Result := 0;
Exit;
end;

ThisTime := GetTickCount(); // Get Time when demo started
SetCursorPos(400,300);

// Main message loop:
while not finished do
begin
if (PeekMessage(msg, 0, 0, 0, PM_REMOVE)) then // Check if there is a message for this window
begin
if (msg.message = WM_QUIT) then // If WM_QUIT message received then we are done
finished := True
else
begin // Else translate and dispatch the message to this window
TranslateMessage(msg);
DispatchMessage(msg);
end;
end
else
begin
Inc(FPSCount);

FrameTime := GetTickCount() - ElapsedTime - ThisTime;
LastTime :=ElapsedTime;
ElapsedTime :=GetTickCount() - ThisTime;
ElapsedTime :=(LastTime + ElapsedTime) div 2;

if GetForegroundWindow = h_Wnd then
begin
GetCursorPos(mpos);
SetCursorPos(400,300);
pView((mpos.x - 400)/100 * MouseSpeed,(300 - mpos.y)/100 * MouseSpeed);
if Player[YouPlayer].Tilt > 89.999 then Player[YouPlayer].Tilt :=89.999;
if Player[YouPlayer].Tilt < -89.999 then Player[YouPlayer].Tilt :=-89.999;
end;

glDraw();
SwapBuffers(h_DC);
ProcessKeys;
end;
end;
glKillWnd(FALSE);
Result := msg.wParam;
end;


begin
WinMain( hInstance, hPrevInst, CmdLine, CmdShow );
end.




Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2002.10.14;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.48 MB
Время: 0.008 c
14-45553
Esu
2002-09-20 07:51
2002.10.14
Пришибли о расизме наконец...


1-45402
Arbin
2002-10-03 10:26
2002.10.14
Элиза


1-45444
Оля
2002-10-03 16:45
2002.10.14
Выполнить процедуры:


4-45645
mskald
2002-08-29 10:50
2002.10.14
Динамические DLL


14-45520
MsGuns
2002-09-17 21:47
2002.10.14
Как достать недозрелых бездельников





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский