flat assembler
Message board for the users of flat assembler.
Index
> Windows > opengl first person camera Goto page 1, 2, 3, 4 Next |
Author |
|
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.
_________________ 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 |
|||||||||||
30 Sep 2008, 00:17 |
|
kasake36 30 Sep 2008, 13:08
well... i tried to download the file but is has an virus in it.
|
|||
30 Sep 2008, 13:08 |
|
windwakr 30 Sep 2008, 13:38
Works fine for me
|
|||
30 Sep 2008, 13:38 |
|
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 |
|||
30 Sep 2008, 15:23 |
|
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?
|
|||
30 Sep 2008, 17:33 |
|
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 |
|||
30 Sep 2008, 20:32 |
|
DJ Mauretto 01 Oct 2008, 05:49
Ciao
Today I managed to download the file, works fine,it's very nice.. Bravo _________________ Nil Volentibus Arduum |
|||
01 Oct 2008, 05:49 |
|
Kenneth 01 Oct 2008, 12:50
Everything renders nicely and the controls work fine.
|
|||
01 Oct 2008, 12:50 |
|
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]. |
|||
02 Oct 2008, 07:58 |
|
DJ Mauretto 02 Oct 2008, 10:47
Ciao
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 _________________ Nil Volentibus Arduum |
|||
02 Oct 2008, 10:47 |
|
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. |
|||
02 Oct 2008, 12:58 |
|
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.
|
|||
02 Oct 2008, 15:06 |
|
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] |
|||
03 Oct 2008, 13:39 |
|
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. |
|||
03 Oct 2008, 14:43 |
|
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. |
|||
16 Nov 2008, 01:53 |
|
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? |
|||
13 Dec 2008, 02:02 |
|
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 That was the only issue... doing opengl stuff in anything seems pretty damn messy and thus some achievement... so doing it using asm!?! Good luck, Kas. |
|||
13 Dec 2008, 02:48 |
|
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 |
|||
13 Dec 2008, 02:58 |
|
bitshifter 13 Dec 2008, 10:39
kas wrote: I wanted to view it but my virus checker seems to have a problem with it. 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:
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. |
|||
13 Dec 2008, 10:39 |
|
Goto page 1, 2, 3, 4 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.