The QB64 Edition

Full Version: TRIANGLE COLORS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
While chatting with a few QB64 programmers on the QB64 chat room, someone had asked if anyone could draw a tri-colored triangle in QB64. They shared a link to a picture of such triangle. I told them that it would be easy to do so, so I sat out to create a demo for it.

Several people suggested that the easiest and most efficient way to do so is with OPEN-GL (or Direct X), which is true since it would hardware accelerated and drawn by the hardware. But, I took the question as if they wanted to know if someone could do it as a software rendering.

Below are some screenshots of the attached demo.

[attachment=206]
[attachment=207][attachment=208]

Please note, this demo demonstrates how to draw a colored triangle and is not optimized in any way. The triangle drawing parts are not in FUNCTIONs or SUBs.



Thanks,
Walter Whitman
The Joyful Programmer
Attached is an updated version of the colored triangle demo. It draws randomly colored triangles at random locations on the screen. The triangle drawing has been placed in a SUB so it could be used in other projects.

The demo is not optimized, so the triangle drawing is slow.

Here is a screenshot:

[attachment=211]
Quote:
While chatting with a few QB64 programmers on the QB64 chat room, someone had asked if anyone could draw a tri-colored triangle in QB64. They shared a link to a picture of such triangle. I told them that it would be easy to do so, so I sat out to create a demo for it.

Several people suggested that the easiest and most efficient way to do so is with OPEN-GL (or Direct X), which is true since it would hardware accelerated and drawn by the hardware. But, I took the question as if they wanted to know if someone could do it as a software rendering.

Below are some screenshots of the attached demo.




Please note, this demo demonstrates how to draw a colored triangle and is not optimized in any way. The triangle drawing parts are not in FUNCTIONs or SUBs.



Thanks,
Walter Whitman
The Joyful Programmer

How about a 3D Triangle ? Walter Wink


Anthony.
Anthony,

This demo only demonstrates software rendering of the colored triangles, not hardware rending like you would make with _MAPTRIANGLE, OPEN-GL, or DirectX.

This demo is only to demonstrate the math behind the rendering.

I guess I will need to post some actual hardware rendered 3D triangles I guess.



Walter Whitman
The Joyful Programmer
Sounds Great Walter...

I imagine 3D Triangles are Quite hard to Produce ? Squares, Oblongs, Circles, I can kind of understand!

And I would also imagine a 3D Pentagon would be a Nightmare! no wonder Devil Worshippers use it! Smile

As for a Dodecahedron...I don't even go there! Big Grin


Anthony.
Anthony,

The triangle was a fairly simple shape to do without a ton of extra stuff. The other shapes would have to be treated like polygons, and the edges scan-converted to get the parts to draw. Though it isn't difficult, it is a little more involved than the triangle.

I plan on creating a polygon demo sometime, but I have been working on one of my games lately, "Medieval Yahtzee".


Thanks,
Walter Whitman
The Joyful Programmer
Awesome!!! Big Grin
Yahtzee you say? Medieval... Hmmm.... Intriguing... Tell us more... lol

J
Dang! I just spent yesterday afternoon working out a triangle fill routine that would work with transparencies so that it wouldn't overlap nor leave gaps. I did find the OpenGL by Walter and posted link at QB64.net my find but I didn't know this was here. (Apparently neither did anyone there?)

Well now I will compare my routine with Walter's, looks like he already has the 3 color thing worked out. Cool! because I had in mind something crazy less to do with triangles and more to do with Voronoi. But let's see what he did...
Reference URL's