You are not logged in or registered. Please login or register to use the full functionality of this board...
The QB64 Edition
TRIANGLE COLORS - Printable Version

+- The QB64 Edition (http://www.thejoyfulprogrammer.com/qb64/forum)
+-- Forum: QB64 (/forumdisplay.php?fid=483)
+--- Forum: QB64 Coders Delight (/forumdisplay.php?fid=8)
+---- Forum: Graphical Demos, Projects, and Special Effects (/forumdisplay.php?fid=10)
+----- Forum: General Graphical Stuff (/forumdisplay.php?fid=74)
+----- Thread: TRIANGLE COLORS (/showthread.php?tid=132)



TRIANGLE COLORS - Waltersmind - 08-16-2014 02:43 AM

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


RE: TRIANGLE COLORS - Waltersmind - 08-16-2014 04:08 AM

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]


RE: TRIANGLE COLORS - Anthony.R.Brown - 08-16-2014 04:57 AM

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.


RE: TRIANGLE COLORS - Waltersmind - 08-16-2014 05:06 AM

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


RE: TRIANGLE COLORS - Anthony.R.Brown - 08-16-2014 06:24 AM

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.


RE: TRIANGLE COLORS - Waltersmind - 08-19-2014 10:57 AM

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


RE: TRIANGLE COLORS - KingAshish - 08-20-2017 04:55 AM

Awesome!!! Big Grin


RE: TRIANGLE COLORS - johnno56 - 08-20-2017 05:26 AM

Yahtzee you say? Medieval... Hmmm.... Intriguing... Tell us more... lol

J


RE: TRIANGLE COLORS - bplus - 08-20-2017 08:28 AM

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...