News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

help - polygon color function doesn't work - glColor3

Started by supercoollee, May 07, 2010, 09:54:45 AM

Previous topic - Next topic

supercoollee

finally! i can go on with GL tutorial now!   :clap:
thanks a lot!

what i don't understand is that ,why in OPENGL.ASM and NEHE's tutorial there is not such a line, but they can show color?
what's more, in NEHE's tutorial , there is not even a lightsource!
isn't it strange?

Tedd

It depends on the combinations of modes you set.

You have GL_LIGHTING enabled, which means light sources are taken into account. If it's not enabled then everything is assumed to be in full light (white ambient light of full intensity.) This also affects how vertices are shaded.
Comment out glEnable(GL_LIGHTING) to see the difference.
No snowflake in an avalanche feels responsible.

supercoollee

i got it , thanks.

i have found new problems:

1) could someone tell me what's the relationship between "wininit" and "mainloop" in this ASM? i found that both proc are looping, not just "mainloop". can i have only one of them looping?


2) i added a timeGetTime function in "doevent", my current way is like this:
=====================
.data
active        db 0
systemtime dd 0
keyptimer   dd 0
...
...
doevent     proc
local   msg:MSG
startloop:
    call    timeGetTime
    cmp eax,systemtime
    jle startloop
    mov systemtime,eax
    cmp key[VK_P],0
    mov al,active
    mov ah,keyptimer
    je  keyptimecount
    test ah,ah
    jne key_p_up
    test al,al
    sete al
    mov active,al
    mov ah,50
    mov keyptimer,ah
    jmp key_p_up
keyptimecount:
    test ah,ah
    je  key_p_up
    dec keyptimer
key_p_up:
    test al,al
    je  pausegame

   (rendering and movement)

pausegame:
    invoke  PeekMessage,addr msg,0,0,0,PM_NOREMOVE
    or eax,eax
    jz startloop
    invoke  GetMessage,addr msg,0,0,0
    or eax,eax
    jz exitloop
    invoke  TranslateMessage,addr msg
    invoke  DispatchMessage,addr msg
    jmp startloop
exitloop:
    mov eax,msg.wParam
    ret
doevent     endp
=====================
in theory, this makes the rendering procedures run 100 times per second. but i read in MSDN that timeGetTime is not accurate, how can i improve the accuarcy? and how can i make the program run 60 or 50 or 30 times per second?

3) and, even if i added delay in "doevent", the program uses up 100% of CPU time, how can i free the CPU when this app is paused? the other winapps don't use CPU when i don't touch them, why?
currently i have an "active" flag in "mainloop".
======================
.elseif umsg == WM_ACTIVATE
    mov al,byte ptr wparam
    test al,al
    jne gamepaused
    mov active,al
    ret
gamepaused:
    call drawscene
    ret

======================
P key can activate/deactivate the app, but it only functions in the way of skipping some lines in "doevent", the app is in fact running (timeGetTime never stops). how can i free my CPU?

qWord

1. a normal GUI program first creates the window and then enter the message loop ('mainloop'). This loop get messages from the system an distributed them to the corresponding windows procedure.
In your program the window is created in wininit. the message loop is also entered from here through a call to doevent, which contains the message loop.

2. look for SetTimer(). As long as you don't need more than 50-60fps this a fine way. (This timer has resolution of  ~15 ms)
This will also sink the CPU usage.
FPU in a trice: SmplMath
It's that simple!