flat assembler
Message board for the users of flat assembler.

Index > Windows > opengl first person camera

Goto page 1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Sep 2008, 00:17
Here is my demonstration of a first person camera in OpenGL.
Note: You must be logged in for attachment to be visible.


Description: Latest Version
Download
Filename: fps.zip
Filesize: 630.95 KB
Downloaded: 1107 Time(s)


_________________
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.


Last edited by bitshifter on 20 Jul 2011, 07:23; edited 17 times in total
Post 30 Sep 2008, 00:17
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 30 Sep 2008, 12:17
Ciao Wink
your file zip give me a error in windows,'unexpected end of the file' Crying or Very sad
I can not extract the files Rolling Eyes

edit:
I tried to download the file several times, but I can not ever get it completely, perhaps the error depends on my internet connection

_________________
Nil Volentibus Arduum Razz
Post 30 Sep 2008, 12:17
View user's profile Send private message Reply with quote
kasake36



Joined: 28 Mar 2006
Posts: 68
kasake36 30 Sep 2008, 13:08
well... i tried to download the file but is has an virus in it.
Post 30 Sep 2008, 13:08
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
windwakr 30 Sep 2008, 13:38
Works fine for me

_________________
----> * <---- My star, won HERE
Post 30 Sep 2008, 13:38
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 30 Sep 2008, 15:23
Works okay, but I see vertical lines between skybox images.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 30 Sep 2008, 15:23
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 30 Sep 2008, 17:33
Same as bitRAKE, I see lines between the squares of the box but works. Pehpaps the textures are not properly mapped?
Post 30 Sep 2008, 17:33
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 30 Sep 2008, 20:32
Ok, I fixed these texture artifacts and re-uploaded the zip.
This was intended to demonstrate first person camera movement.
I was aware of the texturing artifacts but let it slide anyway.
Comments and criticism are greatly appreciated, so thanks.

Code mods for 0.5 pixel shift on uvmap:
Code:
skybox_uvmaps dd 0.001953,0.001953,\
                 0.001953,0.998047,\
                 0.998047,0.998047,\
                 0.998047,0.001953      
Post 30 Sep 2008, 20:32
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 01 Oct 2008, 05:49
Ciao Very Happy
Today I managed to download the file,
works fine,it's very nice..
Bravo Wink

_________________
Nil Volentibus Arduum Razz
Post 01 Oct 2008, 05:49
View user's profile Send private message Reply with quote
Kenneth



Joined: 16 Nov 2005
Posts: 38
Location: United States of America
Kenneth 01 Oct 2008, 12:50
Everything renders nicely and the controls work fine.
Post 01 Oct 2008, 12:50
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 02 Oct 2008, 07:58
Can someone help me clamp the camera_rotation_x value?
Ive been trying to figure it out for two days and no luck.
Using the fpu i would like to clamp within [-60.0~60.0].
Post 02 Oct 2008, 07:58
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 02 Oct 2008, 10:47
Ciao Wink
Code:
; add this variable to data
Clamp_x               DD 60.0

      ; look up/down
         fld     [msg.pt.y]
          fsub    [window_mid_y]
              fdiv    [camera_lookspeed]              ; must be integer
           fadd    [camera_rotation_x]

     fcom    [Clamp_x]
   fstsw   ax
  and     ax,4500h                        ; mask C0,C2,C3
     test    ax,ax                           ; > 60.0 ?
       jz      @Max                            ; Jump if > 60.0

     xor     [Clamp_x],80000000h             ; Flip Sign bit
     fwait
       fcom    [Clamp_x]
   fstsw   ax
  xor     [Clamp_x],80000000h             ; Flip Sign bit
     and     ax,4500h                        ; mask C0,C2,C3
     test    ax,0100h                        ; < -60.0 ?
      jnz     @Min

            fstp    [camera_rotation_x]
 jmp     @f

@Min:
 mov     [camera_rotation_x],-60.0
   fstp    st
  jmp     @f
@Max:
     mov     [camera_rotation_x],60.0
    fstp    st      
@@:

      ; center cursor position
      invoke SetCursorPos,[window_mid_x],[window_mid_y]
      jmp .update    


Note: This code is not optimized,
is just one example of how to proceed with the comparison
float point numbers Smile

_________________
Nil Volentibus Arduum Razz
Post 02 Oct 2008, 10:47
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 02 Oct 2008, 12:58
Ok, thanks DJ, as soon as i study and understand your code sample i will then optimize and include it into the source code in my own way.

I have made more changes to my source code and re-uploaded it.
The most significant was shaving many camera fpu instructions away!

I am learning to use more win32ax stuff so i changed the texture loading code into a proc with local variables and some error checking.
The calling code and some global variables were changed along with it.
Post 02 Oct 2008, 12:58
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 02 Oct 2008, 15:06
Check http://www.x86.org/secrets/opcodes/fcomi.htm (Only PPro, PII and newer. And PMMX?). DJ Mauretto, it can be done more simple by using SAHF.
Post 02 Oct 2008, 15:06
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 03 Oct 2008, 13:39
I have studied DJ Mauretto's code sample and tried a few different ideas.
This is my final result after about four hours of tinkering and optimizing.
I will re-upload the zip later, after a few more changes to the code are made.
Also, LocoDelAssembly: I did read up on your link and it looks like i have to choose between speed and portability, i guess portability wins for now.
Code:
      camera_maxlookup   dd  60.0
      camera_maxlookdown dd -60.0

      fld [msg.pt.y]
      fsub [window_mid_y]
      fdiv [camera_lookspeed]
      fadd [camera_rotation_x]
      fld [camera_maxlookup]
      fcom
      fnstsw ax
      and ax,0x4500
      test ax,ax
      jnz .clamp
      fstp st
      fld [camera_maxlookdown]
      fcom
      fnstsw ax
      and ax,0x4500
      test ax,ax
      jnz .noclamp
   .clamp:
      fxch
   .noclamp:
      fstp st
      fstp [camera_rotation_x]    
Post 03 Oct 2008, 13:39
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 03 Oct 2008, 14:43
Use this form then
Code:
;Example 1: traditional Intel386-compatible code.

        FCOM    ST0, ST1                ; Floating point compare
        FNSTSW  AX                      ; Store floating point flags in AX (no wait)
        SAHF                            ; Move AH to integer flags register
        Jcc     Continue                ; Branch on some condition
        ...                             ; do many instructions in this code block
Continue:
    


[edit]Or at least replace and ax,0x4500/test ax,ax with simple test ax,0x4500.
Post 03 Oct 2008, 14:43
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 16 Nov 2008, 01:53
Hello, i have updated and re-uploaded the source code and demo with a few new changes.
Previously i was just looping to eat processor time in order to get consistent framerates which was kind of wasteful, so i decided to incorporate a time based camera movement system.
The camera now turns/looks/walks/strafes using units per second scalers.
I have also added code to limit the vertical angles of the camera.
This has been tested on Windows XP (Intel Celeron 345-D 3.07ghz) and runs smoothly with no skips or jumps.
As always, any comments or constructive criticism are greatly appreciated.
Post 16 Nov 2008, 01:53
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 13 Dec 2008, 02:02
Is anyone still having problems with downloading my attachment?
Its been a while since anybody has left a comment here...
Is the .zip corrupt or does the demo suck or is it just not interesting?
Post 13 Dec 2008, 02:02
View user's profile Send private message Reply with quote
kas



Joined: 16 Jan 2008
Posts: 36
Location: UK
kas 13 Dec 2008, 02:48
Hi bitshifter,

I wanted to view it but my virus checker seems to have a problem with it. Permalink: http://www.virustotal.com/analisis/93ac20e4c1c1c116240a25b493b5f814

I know that these virus checkers are often making false positives for lots of harmless code written in asm... but as I'm currently must use windows as my main desktop - I'm having to lean on the side of caution Sad

That was the only issue... doing opengl stuff in anything seems pretty damn messy and thus some achievement... so doing it using asm!?! Very Happy

Good luck,

Kas.
Post 13 Dec 2008, 02:48
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 13 Dec 2008, 02:58
Sorry, I haven't look at it before. The demo works good and this time there are no artifacts in the box's sides edges.

Thanks for the fix
Post 13 Dec 2008, 02:58
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 13 Dec 2008, 10:39
kas wrote:
I wanted to view it but my virus checker seems to have a problem with it.
I know that these virus checkers are often making false positives for lots of harmless code written in asm...
but as I'm currently must use windows as my main desktop - I'm having to lean on the side of caution Sad

It is probably due to the fact that i included a compiled executable along with the source code,
and the executable is most likely being flagged as a virus.
kas wrote:

doing opengl stuff in anything seems pretty damn messy and thus some achievement... so doing it using asm!?! Very Happy

The opengl code was just as easy as if i used the 'C' language or any other language,
the challenge for me was to figure out how to use the floating point routines that compliment the applications flow.

The cool part about doing this with fasm is that fasm does not perform any optimizations to my code,
which many C/C++ compilers do automatically, and thus they do not produce the desired result when
pre-filtering messages before deciding to send the message off to the WindowProc or not.
Post 13 Dec 2008, 10:39
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3, 4  Next

< 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.