flat assembler
Message board for the users of flat assembler.

Index > Windows > Strange behaviour of function

Author
Thread Post new topic Reply to topic
dmitriy566



Joined: 19 Jun 2012
Posts: 25
Location: Saint-Petersburg, Russia
dmitriy566 06 Jul 2012, 17:31
Hello!
I want to describe my problem. I write code that switches screen into fullscreen mode and one can draw rectangles by mouse. Firstly i have initialisation:
Code:
invoke  GetClientRect,[hwnd],rc
mov  [drawf],1
call       Init_OpenGL
    

If i comment Init_OpenGL call here but use the same call in WndProc on event WM_CREATE then I have no initialisation and no draw. If i copy code from Init_OpenGL to handler of WM_CREATE(it is commented) it works, but call Init_OpenGL not works. I cannot understand such behavior.
Thank you for explanation.


Description:
Download
Filename: opengl.rar
Filesize: 24.13 KB
Downloaded: 189 Time(s)

Post 06 Jul 2012, 17:31
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 06 Jul 2012, 21:29
Please clarify, does the attached file work without modification?

Because I launched the program and it works - i can draw those rectangles.

Win7 x64
Post 06 Jul 2012, 21:29
View user's profile Send private message Reply with quote
dmitriy566



Joined: 19 Jun 2012
Posts: 25
Location: Saint-Petersburg, Russia
dmitriy566 07 Jul 2012, 05:49
Ok, I can post not working program.
Here:
Code:
invoke   GetClientRect,[hwnd],rc
mov  [drawf],1
;call      Init_OpenGL    

I comment Init_OpenGL
And here:
Code:
call        Init_OpenGL
xor      eax,eax    

I use it. But in this case it not works.
If i uncomment a code upper in handler WM_CREATE, program works.
Post 07 Jul 2012, 05:49
View user's profile Send private message Reply with quote
dmitriy566



Joined: 19 Jun 2012
Posts: 25
Location: Saint-Petersburg, Russia
dmitriy566 07 Jul 2012, 05:50
Sorry, forget post


Description:
Download
Filename: opengl.rar
Filesize: 24.12 KB
Downloaded: 201 Time(s)

Post 07 Jul 2012, 05:50
View user's profile Send private message Reply with quote
bzdashek



Joined: 15 Feb 2012
Posts: 147
Location: Tolstokvashino, Russia
bzdashek 07 Jul 2012, 06:37
The problem was, that you used global [hwnd] in InitOpen_GL, but it gets initialized only after CreateWindow, but WM_CREATEWINDOW get processed during CreateWindow call. So when you call InitOpen_GL, the global [hwnd] variable is NULL.

Code:
 proc Init_OpenGL
        invoke  GetDC,[hwnd] ;hwnd is null
    


I modified the InitOpen_GL, added [hwnd] parameter, so hwnd can be passed to it. Now it works.
Code:
;...
 .wmcreate
    stdcall Init_OpenGL,[hwnd]
;...

 proc Init_OpenGL uses edi,hwnd:DWORD
    invoke  GetDC,[hwnd]
 ;...
    


The second variant: you can also initialize global [hwnd] from WM_CREATEWINDOW handler, but then you should rename it to [hWnd] for example, otherwise you won't be able to access it.


Description:
Download
Filename: opengl.zip
Filesize: 24.87 KB
Downloaded: 197 Time(s)

Post 07 Jul 2012, 06:37
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.