flat assembler
Message board for the users of flat assembler.
Index
> Windows > Where do I put my OpenGL drawing routine? |
Author |
|
typedef 28 Apr 2011, 11:52
put them in the while getmessage loop.
or use setTimer and draw at each interval in either TimerProc or on WM_TIMER |
|||
28 Apr 2011, 11:52 |
|
revolution 28 Apr 2011, 11:55
There is an OpenGL example already in the fasm download.
|
|||
28 Apr 2011, 11:55 |
|
mindcooler 28 Apr 2011, 21:26
How and why do I put it in the getmessage loop? Do I make it a peekmessage loop? What advantage over putting it in the wndproc?
Can I put it in WM_TIMER instead? The GL example I think abuses the message queue or something, it gobbles up an entire cpu core. |
|||
28 Apr 2011, 21:26 |
|
Enko 28 Apr 2011, 21:58
As I understand, you can use 3 options:
1)on WMPAINT in msg LOOP. (But it will be updated only when the windows needs to updated, somthing drawed over your windows) 2)Use a WM_TIMER: only draws when the WMTIMER event is activated. 3)Use peek Msg, this way, is the most used in games, becous as i get it, you dont wait a msg, you intercept it. |
|||
28 Apr 2011, 21:58 |
|
typedef 28 Apr 2011, 23:18
you can just do this.
; This is also good as it gives you control as to when you want to draw ; meaning how many frames per second. SetTimer,[hwnd],[timerId],[interVal],timerProc proc timerProc hwnd, msg,id,elapsed ;TODO GL code here ret endp |
|||
28 Apr 2011, 23:18 |
|
mindcooler 29 Apr 2011, 05:17
The problem is that when my glbegin..glEnd is in a different thread than the wndproc, responding to WM_SIZE and invoking glViewport fails when between glBegin and glEnd.
|
|||
29 Apr 2011, 05:17 |
|
typedef 29 Apr 2011, 05:36
mindcooler wrote: The problem is that when my glbegin..glEnd is in a different thread than the wndproc, responding to WM_SIZE and invoking glViewport fails when between glBegin and glEnd. use global variables or flags.. Code: cmp [msg],WM_SIZE mov [sized],1 .... proc timerProc glBegin cmp [sized],1 je .notSized .notSized: ;//TODO code goes here if window is not re-sized. glEnd Does that help ? |
|||
29 Apr 2011, 05:36 |
|
mindcooler 29 Apr 2011, 16:03
Hmm, I guess. I'll try it out. Then I should be able to contain everything in it's own self-timed thread.
|
|||
29 Apr 2011, 16:03 |
|
bitshifter 30 Apr 2011, 02:42
|
|||
30 Apr 2011, 02:42 |
|
mindcooler 30 Apr 2011, 16:17
Own self timed draw thread using global flags it seems. Sounds like the way to go. But I don't get the peekmessage loop.
2300 fps without the sleep. Mouse input breaks with the sleep. |
|||
30 Apr 2011, 16:17 |
|
mindcooler 01 May 2011, 01:23
Trying to get the aspect ratio correct, 4:3.
Any idea why nothing at all shows up on screen if the values of glOrtho differs even slightly from these values? Code: invoke glMatrixMode,GL_PROJECTION invoke glLoadIdentity invoke glOrtho,1.0,-1.0,1.0,-1.0,1.0 invoke glGetError invoke glMatrixMode,GL_MODELVIEW invoke glLoadIdentity _________________ This is a block of text that can be added to posts you make. |
|||
01 May 2011, 01:23 |
|
bitshifter 01 May 2011, 08:12
My font demo is much simpler and uses ortho projection.
http://board.flatassembler.net/topic.php?t=9885 By convention, opengl sets ortho screen [0,0] at bottom left. You can flip the values to make it top left instead. Also note where double parameters are passed (not dwords but qwords) |
|||
01 May 2011, 08:12 |
|
mindcooler 01 May 2011, 21:32
My example was missing an operand, but I still don't understand what's going on.
Code: invoke glOrtho,1.0,-1.0,1.0,-1.0,1.0,-1.0 Gives an error 501 and probably defaults to some standard view, showing my cube. Code: invoke glOrtho,1.001,-1.001,1.0,-1.0,1.0,-1.0 gives no error, but present a black screen. -----realization: glOrtho expects doubles------ I tried glFrustum too, with similiar results: (I can't use x headers) Either it fails with error 501 and presents my cube orthogonally, or it accepts the operands and shows nothing. Code: mov esi,frustum push dword [esi+40] push dword [esi+44] push dword [esi+32] push dword [esi+36] push dword [esi+24] push dword [esi+28] push dword [esi+16] push dword [esi+20] push dword [esi+08] push dword [esi+12] push dword [esi] push dword [esi+04] invoke glFrustum What operands should I use if I just want to show my sidelength 1 cube that sits in the origin? Do I pass the parameters correctly? _________________ This is a block of text that can be added to posts you make. |
|||
01 May 2011, 21:32 |
|
bitshifter 02 May 2011, 02:31
Take my wgl font demo (wglfont.asm) and plug this into it...
Code: ; TODO: Render 2D shit here... invoke glPushMatrix invoke glTranslatef,256.0,256.0,0.0 ;x = 256, y = 256 (pixels from bottom left) invoke glColor3ub,255,255,255 ;white invoke glBegin,GL_QUADS invoke glVertex2i,-10,-10 ;10 pixels width,height (z = 0) invoke glVertex2i,-10,10 invoke glVertex2i,10,10 invoke glVertex2i,10,-10 invoke glEnd invoke glPopMatrix Doing it in 3D with ortho is no different except 3D vertices with glVertex3* Also translating to screenwidth/2, screenheight/2 puts it center of screen. Make sure you know exactly what a function does before using it. Hope this helps Ramble: I am thinking of OpenGL tutorial series for FASM. If enough people show interest i may do it... _________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. |
|||
02 May 2011, 02:31 |
|
mindcooler 02 May 2011, 17:08
I have no trouble with the modelview matrices, only getting the perspective matrix going.
I pushed the doubles in the wrong order, with this I actually get something with some kind of perspective on screen: Code: mov esi,frustum push dword [esi+44] push dword [esi+40] push dword [esi+36] push dword [esi+32] push dword [esi+28] push dword [esi+24] push dword [esi+20] push dword [esi+16] push dword [esi+12] push dword [esi+08] push dword [esi+04] push dword [esi] invoke glFrustum frustum dq 5.0,-5.0,5.0,-5.0,0.1,5.0 _________________ This is a block of text that can be added to posts you make. |
|||
02 May 2011, 17:08 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.