Shop OBEX P1 Docs P2 Docs Learn Events
OpenGL or equivalent — Parallax Forums

OpenGL or equivalent

aanrudolph2aanrudolph2 Posts: 4
edited 2010-08-28 09:34 in Propeller 1
Hi, all.

I know I (and others) have asked about 3D graphics on the Propeller platform before. The answers I remember receiving were things like "too little RAM" and whatnot.

I have a couple of follow-up questions regarding this issue. (1) Exactly how much RAM is required to produce a simple OpenGL functionality on a Propeller-based platform? I am aware the Propeller has about 32k onboard, but I believe, using external circuitry, that can be expanded by a significant amount. (2) Where would be a good starting point to find basic algorithms for drawing polygons and whatnot for beginning this ambitious project? (3) How many people do you (as the responder to this post) know have tried and failed at simulating OpenGL on a Propeller?

I appreciate it.

Aaron.

Comments

  • Heater.Heater. Posts: 21,230
    edited 2010-08-26 06:04
    Oh boy,

    The core Open GL library on my Debian Linux box here is 14M Bytes!

    Perhaps one can get it down to a tenth that size, after all the Mesa OpenGL implementation used to run on Amigas., but you are still going need heaps of external RAM. Maybe Jazzed's 32MByte solution.

    It's going to be slow. Might as well render your polygons with a chisel on a stone tablet.

    Better to use one of those new ARM processors with OpenGL hardware acceleration built in. As used in my Android phone. Then hook that up to a Prop or two to make use of it's I/O. That's my plan anyway.
  • potatoheadpotatohead Posts: 10,261
    edited 2010-08-26 07:42
    Doing simple graphics primitives works on Propeller. Baggers has setup low resolution poly displays.

    This kind of thing happens at moderate TV resollution. Coupla hundred pixel screen tops, and it takes most of a Propeller to do.

    Baggers and Coley built a serially controlled propeller graphics system. It's approachable for games and such.

    The other thing we have is Chip Gracey's graphics COG. It's filled with 2D primitives, and works on a command basis. That cog can be told where a bitmap display is, and what it's coordinates should be. From there, one can put commands into a HUB buffer, to be run by that COG, on the display. It's capable of simple shapes, line, arc, text, filled shapes. It can also do some simple windowing and buffering.

    (not window like a pc, but a window as in a portion of a display being operated on, or buffered)

    Have you run graphics_demo.spin? If not, do that, or look at the code for it, which is included with the free downloadable IDE. That's a great example of where the Propeller is graphically.
  • aanrudolph2aanrudolph2 Posts: 4
    edited 2010-08-26 11:50
    Ouch. Okay. So...I guess my first question is this: why is it so slow? I mean, really all one is doing is calculating where to draw the polygons based on a simulated 3D environment, correct? Or is it the calculations that slow everything down? Or do I have this completely wrong?
  • LeonLeon Posts: 7,620
    edited 2010-08-26 12:00
    Stuff like matrix algebra and quaternions is involved, which takes a great deal of computation. Where I once worked we used top of the range Silicon Graphics machines for 3D graphics using OpenGL, with dozens of pipelined floating-point processors.
  • lonesocklonesock Posts: 917
    edited 2010-08-26 12:09
    OpenGL has many different levels. Even targeting something very old, like OpenGL 1.1 would be beyond the propeller. If you wanted to limit yourself to a subset of the functionality (like single color flat-shaded triangles only), I'm sure you could get there on the prop.

    One issue that hasn't been covered is you need a way to make sure that near triangles cover up the far triangles. The typical ways to do this are a depth-buffer (storing the depth of each pixel drawn so far), which is _not_ feasible on the prop, and the "painter's algorithm", where you draw everything in order from far to near. This requires a fast sort algorithm, and the overdraw can be horrible, and sometimes the order can still be wrong (imagine 2 intersecting triangles, at an angle to each other...there's no draw order that works in all cases. (There are many other options, but these are the easiest and most common).

    You may want to check out http://bellard.org/TinyGL/, as a nice software implementation of some OpenGL functionality.

    Jonathan
  • BaggersBaggers Posts: 3,019
    edited 2010-08-26 12:10
    Ouch. Okay. So...I guess my first question is this: why is it so slow? I mean, really all one is doing is calculating where to draw the polygons based on a simulated 3D environment, correct? Or is it the calculations that slow everything down? Or do I have this completely wrong?

    Why is it slow... well, it's not that "simple" for starters, here's a list of reasons that I can think of off the top of my head without thinking too heavily into this reply.

    1. There is NO multiply/divide in hardware, it all has to be done in software, so you get your XYZ, then you have to do a World Matrix calculation, to take it from it's local space to 3D space, then you have to do a Camera Matrix calculation to get it into a local camera space, then you have to do a Perspective Matrix calculation, to then give you screen coordinates. so for each vertex you need a few calculations, you can concatenate all them into one matrix, so that you then only have to do one set of matrix multiplies per vertex.

    2. You have to do those calculations to EVERY vertex in your model, re-adjusting the World Matrix when you use a different model. ( Also, this isn't including models with Bones, that takes things to another level of slowness. )

    3. You then have to get the propeller to physically draw it, so then depending on which method you choose in rendering your poly, say you're not wanting to slow down things a lot more, doing gouraud shading, or textures, ( as you then need to take into consideration, blending and more delta's for traversing through the poly rendering. ) so just with flat shading, you need the delta values for traversing down the edges of the triangles, then you need to fill in the ram, now again, this can get slower if you don't have byte per pixel, and if you have to then add bit manipulation, to fill the horizontal strip.

    So, Yes, OpenGL has made it too easy for programmers to get things onto the screen on PCs and Macs, because the hardware graphics cards take a lot of the calculations away from you, where-as on the propeller, it's just the propeller, your code has to do EVERYTHING, from calculating where to put the vertex to what part of memory that you've set aside for screen to then fill with values to set the new pixel colours.
  • potatoheadpotatohead Posts: 10,261
    edited 2010-08-26 13:39
    ...I would add the perspective calculation could be skipped, if the resulting display is an orthogonal one.

    Not much of a savings, but some little savings.

    (great post Baggers)
  • pharseidpharseid Posts: 192
    edited 2010-08-26 21:37
    I got the source code for the non-functioning Intel Graphics Language (anyone else ever heard of that?) and got it running in the early 90's. It used the z-buffer algorithm and Gouraud shading; I would have implemented texture mapping but by that time I could see OpenGL and Direct3D were coming for the PC. I remember it being about 4000 lines of code. If you can live in a 16-bit world space, you can use a fixed point 16.16 format to do interpolations for rendering, which is the way to go on an interger cpu. Because the z-buffer won't fit into the Prop's RAM, you need to use the Painter's algorithm or something.

    If your goal is to get 3D running on the Prop, it's probably just barely doable. But it will really make you yearn for the Prop ][. If you want to run OpenGL, the idea about using an ARM with an OpenGL accelerator is probably the best idea.

    -phar
  • ErNaErNa Posts: 1,753
    edited 2010-08-26 22:59
    Writing software is always a challenge and one may search for a high handycap to be more satisfied. So why not develop a graphics driver working sufficiently on the prop I, adding some memory as done by Bill and others, sharing work load to parallel running props and later swap to prop ][ or ]I[. A lot of incredible, but existing solutions are already out of range to me and the most! Good luck!
  • Heater.Heater. Posts: 21,230
    edited 2010-08-27 02:26
    pharseid,

    You remind me of something, in the days of 25MHz 386 PCs with no floating point running MSDOS we had a 3D demo. In the demo was a model of some suburban streets, bungalows, gardens, roads, trees etc. There were occasional people walking around and cars on the roads. You could get a drivers eye view as you drove your car around.

    Amusingly you could park your car in front of a pedestrian and he would continue his walking action without making any progress. Or you could drive through the walls of a house and checkout the inside of the living room.

    No idea if this was from Intel but it was a pretty amazing demonstration of what can be done with such limited processing power.
  • pharseidpharseid Posts: 192
    edited 2010-08-27 08:05
    Heater,

    My understanding was that I was like one of two users of IGL and, as I mentioned, it was not a functioning product, I had to do a bit of work to get it running. I would think the demo you saw was more optimized than IGL, my memory was that things didn't get interesting until you got over 100 MHz. But from my little exposure to 3D graphics programming I could see that there were a lot of shortcuts you could take to get 3D on a slow integer cpu; living in a 16 bit world space, not doing the full [4x4]x4 transform, using fixed point math instead of floating point.

    To quantify things, I would think you could get something like the original Doom graphics without the texture mapping on the Prop. If you have to go to external memory to read in texture maps, things would really slow down. In order to render shading in low-res modes I used dithering; the result was surprisingly good. To be useful, somebody would have to write code to read in some standard 3D format, then you'd be able to use 3D modeling software to create content. I remember in my own case when I got the renderer running, I discovered it would be infinitely more work to create content without modeling software than it was to display it.

    But I think this thread illustrates the reality that there isn't really that much interest in 3D on the Prop or we'd already be there. From what I've read about the Prop ][ it will be far more 3D capable. From a game programmer's standpoint, when you get to the point where you can display Quake 1-3 era models and the .MAP level format, you have access to a huge amount of existing content. You get those hard-core Prop game programmers to do something interesting and then you're off and running.

    -phar
  • lonesocklonesock Posts: 917
    edited 2010-08-27 08:26
    By the way, on the topic of transformations, there are CORDIC-like equations for quaternions. I have never seen them used for a fixed-point embedded 3-D application, but it seems to me they would fit well.

    Jonathan
  • Heater.Heater. Posts: 21,230
    edited 2010-08-27 08:43
    Well , there were 3D wire frame games like Star Glider for the Atari ST with its 8 MHz processor and no floating point. I believe it ran on the lowly Spectrum as well.

    Star Glider on the Prop would be nice. It's about the last computer game I ever played.
  • ericballericball Posts: 774
    edited 2010-08-27 09:10
    pharseid wrote: »
    To quantify things, I would think you could get something like the original Doom graphics without the texture mapping on the Prop. If you have to go to external memory to read in texture maps, things would really slow down.
    Considering Wolf-3D required 640K and even a 160x120 bitmap would use 19K, I don't think the Prop I has any chance of creating a 3-D world display.
  • LeonLeon Posts: 7,620
    edited 2010-08-27 09:11
    I'm responsible for Star Glider, in a way. I started the National TRS-80 Group and one of our members did some programming for Jez San's father, who had a TRS-80 Model I for his business. Jez learned programming on that machine. I first met him when he was a rather precocious 14 year old.
  • BaggersBaggers Posts: 3,019
    edited 2010-08-27 09:27
    ericball wrote: »
    Considering Wolf-3D required 640K and even a 160x120 bitmap would use 19K, I don't think the Prop I has any chance of creating a 3-D world display.

    ericball, did you not see my wolfenstein render demo? :) on a single prop with no added memory too!
  • ericballericball Posts: 774
    edited 2010-08-27 10:19
    Baggers wrote: »
    ericball, did you not see my wolfenstein render demo? :) on a single prop with no added memory too!
    If you've done it, I'll humbly eat my words.
  • ColeyColey Posts: 1,112
    edited 2010-08-27 10:23
    You'd better start tucking in then :lol:

    http://www.youtube.com/watch?v=6vp5krplhxE
  • LeonLeon Posts: 7,620
    edited 2010-08-27 10:26
    I've actually seen it running.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-27 10:28
    Propeller land, the place where impossible things are done all the time.

    Coley, brilliant!.
  • ColeyColey Posts: 1,112
    edited 2010-08-27 10:30
    All the credit goes to Baggers heater, he is a genius :smilewinkgrin:
  • BaggersBaggers Posts: 3,019
    edited 2010-08-28 09:27
    ericball wrote: »
    If you've done it, I'll humbly eat my words.

    Don't worry, you won't have to humbly eat those words. :D
  • BaggersBaggers Posts: 3,019
    edited 2010-08-28 09:34
    Coley wrote: »
    All the credit goes to Baggers heater, he is a genius :smilewinkgrin:

    Cheers Coley :D not sure about genius though!
Sign In or Register to comment.