Author Topic: nGL - a fast (enough) 3D engine for the nspire  (Read 269790 times)

0 Members and 2 Guests are viewing this topic.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #15 on: November 28, 2013, 04:35:32 pm »
Simple but awesome proof-of-concept O.O

I feel like I'll be doing something to see how powerful it is ...
* Matrefeytontias is planning things, be ready people
« Last Edit: November 28, 2013, 04:35:48 pm by Matrefeytontias »

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #16 on: November 28, 2013, 04:36:29 pm »
Not really, it needs three division per horizontal line (z, u and v) and the pixel() function checks whether the pixel is visible (clipping and z-buffer). It basically scales linear to height, but I'll improve that once I implement triangle clipping.

Edit: If you're reading this and getting confused, this is a reply to the second last post :P
« Last Edit: November 28, 2013, 04:47:08 pm by Vogtinator »

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #17 on: November 28, 2013, 04:37:29 pm »
By the way, what attachment should I download to have the latest version of the nGL lib ?

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #18 on: November 28, 2013, 04:39:56 pm »
Just the snake3d_something.tar.gz. the only snake specific parts are the textures and main.cpp.
If you want to I can give you a tool to convert images (png, gif, jpeg, tiff...) to header files with filled TEXTURE structs.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #19 on: November 28, 2013, 04:40:24 pm »
Yeah I might want to use that :)

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #20 on: November 28, 2013, 04:44:38 pm »
Beware: It's written in C++ (with Qt), source code and binary for x86_64 linux attached. It's sort of hacked together (doesn't even show whether the file exists), but it should work.
./ConvertImg test.png >> textures.h and then #include "textures.h" and use the texture with glBindTexture(&test);

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #21 on: November 28, 2013, 04:50:25 pm »
And if I use Windows ? <_<

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #22 on: November 28, 2013, 05:13:28 pm »
And if I use Windows ? <_<
Then use drapes.

edit : More seriously, Qt development tools exist for Windows, just google it and compile it yourself.
« Last Edit: November 28, 2013, 05:15:07 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #23 on: December 19, 2013, 03:02:03 am »
So, I fixed a few bugs in nGL (fewer crashes) and converted my snake game (I made exactly one year ago) to 3D.
No special features, just plain snake.
You can still move around and look.
The apple is just a cube with apple texture (I found on the internet), I couldn't find a suitable 3D model of an apple and I can't use blender.
Every block on the screen is drawn and textured completely, the game isn't optimized at all (walls between two wall blocks) but still runs smooth.
Sorry, but I'm more programmer than game designer and I just couldn't do it any better...

Controls: 8-6-4-2: Move snake
                WASD: Move around (for testing with nspire_emu)
                touchpad: Look around


Nice HP Prime game! Oh wait nvm it's Nspire :P (it just reminded me a bit of the 3D thing I made, except it was actually pseudo 3D in my case)

I like how this library is turning out so far. :)

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #24 on: December 24, 2013, 08:30:17 pm »
UPDATE!  ;D

I made some progress on nGL and made another demo (which is again, not intended to be "played"): crafti!

Changes:
  • Faster! A lot faster, actually. I can't tell any numbers, but with large triangles it went from slow to smooth :hyper:
  • Interpolating colors between vertices, which is actually slower than textured rendering
  • Prefixed functions with ngl (for example nglInit)
  • Something like vertex arrays (nglAddVertices)
  • Wireframed rendering
  • Doesn't crash anymore
  • Some documentation
  • Clipping! (X: Per pixel Y: Per line Z: Per triangle)

Todo:
  • Colored textures (non-interpolated)
  • Compressed textures (zlib). nGL doesn't lose performance with higher-resolution images, they just get too big in raw format
  • Make a real, playable, good looking game which uses nGL
  • FPS counter

It looks a lot better on the emulator and on calc than these gifs (byzanz-record is crap):

(The emulator runs at 90% speed here, I accidentially hit F9)

The textures used aren't mine this time, terrain.png came from http://www.planetminecraft.com/texture_pack/fancycraft-by-jjjas0n-64x64-version-100.
Also, the controls (same as nGL in the first post) are a bit weird to use on a PC so the twitches you see are just my fingers finding the keys.

It's a bit slower on calc than on the emulator, I suspect it's the touchpad polling every frame, but if that get's a real issue, I'll take care of that.
If you want to use nGL, grab gl.cpp, gl.h, fastmath.h, fastmath.cpp, fix.h and don't forget to read gl.h and #define SAFE_MODE in gl.h!

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #25 on: December 24, 2013, 08:37:08 pm »
It's a bit slower on calc than on the emulator, I suspect it's the touchpad polling every frame, but if that get's a real issue, I'll take care of that.
If you want to use nGL, grab gl.cpp, gl.h, fastmath.h, fastmath.cpp, fix.h and don't forget to read gl.h and #define SAFE_MODE in gl.h!
I notived that on my nAk3d project (dropped down due to your way better GL implementation :D ).
This is indeed due to pooling, touchpad or keypad, both are time critical for something running on 30fps.
For example, my first attempts ran on emulator at 200fps, but only 16 fps on calc. I removed keypad pooling and it then raised to 120fps.
notice : This problem is not visible on emulator due to not emulating mapped memory access delays.

I then managed to create a keypad pooling without using an interruption handler. It uses the ndless code of sleep.c that setup an arm co-processor to wakeup the arm processor when a certain time has arrived. This let me cleverly set my keypad pooling without spamming at each frame.
« Last Edit: December 24, 2013, 08:39:35 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #26 on: December 24, 2013, 08:39:58 pm »
Wow, this is insanley fast&smooth *.*
Great job! :thumbsup:

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #27 on: December 24, 2013, 08:50:11 pm »
Quote
I then managed to create a keypad pooling without using an interruption handler. It uses the ndless code of sleep.c that setup an arm co-processor to wakeup the arm processor when a certain time has arrived. This let me cleverly set my keypad pooling without spamming at each frame.
Or I register a function as a keypad interrupt handler which sets some bits of keys currently pressed to 1.
I'll have to implement interrupt support for the FPS counter (timers :/) anyway...

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #28 on: December 24, 2013, 09:46:42 pm »
This is looking pretty impressive. Nice work Vogtinator! :)

Offline fb39ca4

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1749
  • Rating: +60/-3
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #29 on: December 24, 2013, 11:41:44 pm »
The Nspire has timers you can use to calculate framerate/frametime.

http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#900D0000_-_Second_timer