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

0 Members and 2 Guests are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #30 on: December 25, 2013, 01:01:37 am »
Wow, this looks fantastic! Are you able to make a 3D snake that is in a cube instead of a plane? The snake could always go in one direction (away from the screen?) and the player just rotates the view of the box in order to steer the snake. Just an idea ^^

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 #31 on: December 25, 2013, 12:50:46 pm »
You mean controls similiar to a rubik's cube?
(Except rotating the individual rings of course)

Edit: FPS counter works now. 100+fps in wireframe mode,  50 in color mode, 30 with textures and 25 with interpolated colors.
But I get some issues with the keypad/touchpad interrupts. If I enable IRQ 16, it just freezes on the real calculator, it works on the emulator.
I acknowledge by writing ~0 to 900e0008 and 900e0044. Can someone give me a clue what might be wrong here?
« Last Edit: December 25, 2013, 06:52:30 pm by 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 #32 on: December 25, 2013, 11:10:46 pm »
Now that I think about it, 3D snake would be too easy.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #33 on: December 26, 2013, 02:48:55 pm »
Now that I think about it, 3D snake would be too easy.
Depends. At first yeah, you are doing it on purpose if you hit something. But when you start being long, you don't see where your tail is when it is not on the face your head is on ;)
And it can be even worse if there are walls and you don't know where.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

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 #34 on: December 26, 2013, 02:51:27 pm »
Since a regular snake is a bent 1D object in a 2D world, I wonder how one could control the analog, a bent 2D object in a 3D world.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #35 on: December 26, 2013, 03:37:00 pm »
Well it's written nowhere that you have to do +1 on both numbers ;)
It would be a bent object in a 3D world yes, but still a 1D object.
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

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 #36 on: December 26, 2013, 03:46:09 pm »
Just speculating there. Another simple game you could try writing is a 3D, as in 6DOF, maze.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #37 on: December 26, 2013, 04:53:54 pm »
The way I make snake games, is I have a buffer of coordinates and to increment the snake, I erase the tail, shift the buffer down, and add a new head at a coordinate computed by the direction you are turning.

You *could* do a snake game where the arena is stationary, the snake always moves forward, and can turn left/right/up/down. However, the controls would get very confusing, especially if you turn the snake upside down. Instead, it would be much easier and probably more fun and cool looking if you rotated the arena and kept the snake oriented the same. Of course, you would have to redraw every element of the snake each time, but that looks like it would be trivial with this engine. To visualise, the head would always be centered in the screen, facing away from the camera, looking in the direction the camera is looking. When you turn left/right/up/down, you could use a different sprite for those directions, but still centered. Then, you just change the camera angle. Incrementing the snake would have to be done based on the current view angles, and you would have to increment it with the camera.

You could just call it a dragon and pretend you were riding one and steering it.

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 #38 on: December 28, 2013, 08:23:09 am »
Or something like http://www.heavygames.com/snake3d/playgame.asp?
With or without transparency (I'm confident in the nspire's performance ;) )?
« Last Edit: December 29, 2013, 08:11:34 pm by Vogtinator »

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 #39 on: December 31, 2013, 01:54:30 am »
One idea I had for a 3D Snake was in the space and with the ability to go in every direction (360° vertically and horizontally), but it would need multiple fruits to eat at once, else a radar would be needed to avoid spending 10 minutes trying to find the next fruit.
« Last Edit: December 31, 2013, 01:55:03 am by DJ Omnimaga »

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 #40 on: December 31, 2013, 09:15:53 am »
That would get really confusing, especially the controls :/

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 #41 on: January 04, 2014, 05:56:12 pm »
True, although I guess if there were many apples to eat it wouldn't be too bad. The problem would probably be coding movement since you could move in every direction.

Anyway, when posting this, I totally missed the other screenshots on the previous page or they were not showing up:

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!

Do you think this engine would be powerful enough for a Minecraft game? O.O Chockosta made one in Lua with no textures but it ran at 10 FPS at 230 MHz, even if it only rendered stuff within a three tiles radius. O.O

Offline The_King

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 247
  • Rating: +6/-2
  • Ⓣⓗⓔ Ⓖⓐⓜⓔ ⓍⒹ
    • View Profile
Re: nGL - a fast (enough) 3D engine for the nspire
« Reply #42 on: January 04, 2014, 05:58:35 pm »
hmm if this is successful mine craft 3d will be easy enough

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 #43 on: January 04, 2014, 06:28:49 pm »
Quote
Do you think this engine would be powerful enough for a Minecraft game?  Chockosta made one in Lua with no textures but it ran at 10 FPS at 230 MHz, even if it only rendered stuff within a three tiles radius.
"crafti" runs at > 20 fps with textures and ~50 without, so it should be possible to play with.
I'm currently working on a game using nGL, but it's not ready yet.
However, I could also imagine some kind of "Portal" game with real portals (move camera to other portal, render into buffer, bind buffer to texture, render portal with texture) which would certainly run fast enough if the level geometry isn't too complex.
Chockosta didn't code ncraft in lua (That would be a PITA, really) he did in in C, but with floats. It would run much faster if he would use fixed-point math like nGL does. Also, nCraft is more optimized to render blocks (culling etc.) so it could turn out even slightly faster than nGL now.

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 #44 on: January 04, 2014, 08:05:48 pm »
Oh wait I thought that it was in Lua. I guess I forgot. >.<