flat assembler
Message board for the users of flat assembler.

Index > Windows > Opengl 3D Rotate

Author
Thread Post new topic Reply to topic
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 03 Jun 2008, 14:49
Hello Smile
Here there is a simple example of 3D cube rotation with Opengl library. Wink
Have fun!

_________________
Nil Volentibus Arduum Razz
Post 03 Jun 2008, 14:49
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4209
Location: vpcmpistri
bitRAKE 03 Jun 2008, 15:48
Reading the code is almost like looking at the disassembly. Shocked

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 03 Jun 2008, 15:48
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 03 Jun 2008, 15:53
Laughing Laughing Laughing
I'm sorry , i like low level programming , i don't know High level Windows programming.
Stop to INVOKE please Wink

_________________
Nil Volentibus Arduum Razz
Post 03 Jun 2008, 15:53
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 03 Jun 2008, 18:49
Code:
section ".code" code readable
    

Doesn't look very "readable" to me Very HappyVery HappyVery Happy LOL
Post 03 Jun 2008, 18:49
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 03 Jun 2008, 19:40
Ok I'll try to optimise the code and the source Embarassed
Now i'm tired , maybe tomorrow ( i'll find my way Smile

_________________
Nil Volentibus Arduum Razz
Post 03 Jun 2008, 19:40
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4209
Location: vpcmpistri
bitRAKE 04 Jun 2008, 02:33
DJ Mauretto wrote:
Laughing Laughing Laughing
I'm sorry , i like low level programming , i don't know High level Windows programming.
Stop to INVOKE please Wink
The point really is: is there a difference between
Code:
    PUSH    Dword [EAX+8]
       PUSH    Dword [EAX+4]
       PUSH    Dword [EAX]
 CALL    [glTranslatef]    
...and,
Code:
    INVOKE  glTranslatef,[EAX],[EAX+4],[EAX+8]    
? Not any difference in the code produced - just less lines to read. If there is some optimization taking place or needed then the verbosity is justified. Otherwise you're just ignoring the fact that FASM is a macro assembler - choosing to use the macros in one capacity, but not another.

Sometimes I do like commenting each PUSH myself though. So, I'm not really being critical, but rather wondering if there is a hidden intent. Maybe, you are working towards an OpenGL template for some size-optimized demo coding?

hInstance is always the base address (default is $400000). Unless relocation information is included AND windows decides to relocate the program it is constant.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 04 Jun 2008, 02:33
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 04 Jun 2008, 10:54
Quote:
So, I'm not really being critical, but rather wondering if there is a hidden intent.

No one hidden intent , it's only my coding style , i like pure assembly , I find myself more comfortable with numbers, i'm not expert in windows or opengl programming , this is only a ordinary example.
Arrow

_________________
Nil Volentibus Arduum Razz
Post 04 Jun 2008, 10:54
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 04 Jun 2008, 11:20
I dislike drawing time synchronization - cube rotates too fast. Also too much uppercase =)
Post 04 Jun 2008, 11:20
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 04 Jun 2008, 12:15
Quote:
I dislike drawing time synchronization - cube rotates too fast

There is no time sync , to adjust speed ( experimental way) in data section decrement this:
Code:
;---------------------
; Angle Increment
;--------------------

IncAngX         DD 0.3                    ; X speed rotate
IncAngY           DD 0.8                    ; Y speed rotate
IncAngZ           DD -1.0                   ; Z speed rotate    

Quote:
Also too much uppercase =)

I dislike lowercase Wink

_________________
Nil Volentibus Arduum Razz
Post 04 Jun 2008, 12:15
View user's profile Send private message Reply with quote
Raedwulf



Joined: 13 Jul 2005
Posts: 375
Location: United Kingdom
Raedwulf 04 Jun 2008, 15:56
Yea, just most fasmers use lowercase while MASMers use uppercase.
Post 04 Jun 2008, 15:56
View user's profile Send private message MSN Messenger Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 04 Jun 2008, 16:51
I tried to make the source more readable, I hope enough Wink

_________________
Nil Volentibus Arduum Razz


Last edited by DJ Mauretto on 18 Nov 2011, 20:25; edited 1 time in total
Post 04 Jun 2008, 16:51
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4209
Location: vpcmpistri
bitRAKE 04 Jun 2008, 19:51
Should message processing always skip scene drawing, or should drawing take place before/after message processing? Could several messages force a noticeable delay?

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 04 Jun 2008, 19:51
View user's profile Send private message Visit poster's website Reply with quote
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder 04 Jun 2008, 21:01
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:58; edited 1 time in total
Post 04 Jun 2008, 21:01
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 05 Jun 2008, 09:23
Hello Smile
First of all i repeat that i'm not an expert windows programming, I am not a programmer, I just fun, I like pure assembly ,Hardware and System.

Quote:
Should message processing always skip scene drawing, or should drawing take place before/after message processing? Could several messages force a noticeable delay?

Yes,let you optimise my example,Windows API are boring,the real programmer
don't write code with API. Wink
Quote:
i dont understand few things...
why you alloc structures inside code with such ammount of 0?

Where ?
Post code section.
Quote:
is that wrong?
Code:
        PUSH    0 
        CALL    [GetModuleHandleA] 
        MOV     [hInstance],EAX
 
    

Why?
When lpModuleName is NULL ,this call give me the module handle of caller.
Quote:
why you pass it to createwindowexa? i call it with 0, and its ok

I don't know,I have always done this way, I never detailed planning Windows API
Quote:
Code:
PeekMessageA
    
why not getmessagea?
PeekMessage unlike GetMessage not expect that a message is present in the queue.
Quote:
and why you destroy eax? it can be -1, 0, or >0

Where ?
Post code section
Quote:
Code:
CALL    [ExitProcess]    
why dont you return it to kernel32? You dont spawn any threads at all.

I don't know I have always done in this way,let you optimise.

_________________
Nil Volentibus Arduum Razz
Post 05 Jun 2008, 09:23
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4209
Location: vpcmpistri
bitRAKE 05 Jun 2008, 22:38
DJ Mauretto wrote:
Yes,let you optimise my example,Windows API are boring,the real programmer don't write code with API. Wink
I'm not really taking about optimization, but rather process dynamics - which any real programmer should be concerned with.
Code:
@LoopMessage:

        CALL    Draw

        PUSH    1                               ; wRemoveMsg = PM_REMOVE
        PUSH    0                               ; wMsgFilterMax
        PUSH    0                               ; wMsgFilterMin
        PUSH    0                               ; hWnd
        PUSH    OFFSET Mes                      ; lpMsg
        CALL    [PeekMessageA]                  ; Read Message from queue
        OR      EAX,EAX                         ; Message ?
        JZ     @LoopMessage

        CMP     [message],12H                   ; WM_QUIT ?
        JZ      @F

        PUSH    OFFSET Mes                      ; lpMsg , Address Message Structure
        CALL    [DispatchMessageA]              ; Send Message  
        JMP     @LoopMessage    
...is how I imagine it could be, but does it really change anything? It seems to prioritize drawing over the message queue processing - allowing only a single message between draws. Confused But doesn't change anything for this example - it still twitches with system fluctuation and consumes any idle process time.

For fun I opened several windows with spinning boxes. Very Happy

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 05 Jun 2008, 22:38
View user's profile Send private message Visit poster's website Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 06 Jun 2008, 07:54
Good test bitRAKE Wink
Unfortunately windows API are as a closed box,I can not write code if I can not control every single statement, which is why I'm not worried examples that use prepackaged libraries.
If you want to see something dynamically optimized Razz , I wrote 16bit examples of 3D rotations, search in DOS section

_________________
Nil Volentibus Arduum Razz
Post 06 Jun 2008, 07:54
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.