Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: AndyA on April 12, 2021, 05:47:09 pm
The Rosetta Code task name is 'OpenGL'. ( https://rosettacode.org/wiki/OpenGL)
Had a hard time finding what it is we're supposed to be looking for. Did you already submit the code to Rosetta Code? I didn't see a 'QB64' entry.
I dunno, maybe a SLEEP: SYSTEM at the end instead DO:WHILE loop, to keep CPU usage to a minimum.
By the way, nice, concise, clean code for the triangle.
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: TempodiBasic on April 12, 2021, 07:26:29 pm
Hi AndyA thanks to evaluate my task.
Yes maybe better to post the link of the task! I'll do next time.
Quote
Did you already submit the code to Rosetta Code? I didn't see a 'QB64' entry
I've posted before here to show the task to QB64 friends. I'll post soon if there is no better code to show.
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: AndyA on April 12, 2021, 09:43:00 pm
TempodiBasic,
Just a silly question, as I know nothing about OpenGL, is there a way to make the triangle cover the whole 600x600 screen?
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: TempodiBasic on April 13, 2021, 06:02:21 pm
@AndyA the OpenGl graphic system has its own cohordinates and its primitive graphic functions.... the range of Y cohordinates is -1(bottom) +1 top --> the Y increases from bottom to top while in the standard graphic it goes from top to bottom the range of x cohordinates is -1 (left) +1(right) the center of the screen is 0,0 as you can see here. https://raw.githubusercontent.com/AshishKingdom/OpenGL-Tutorials/gh-pages/images/first-triangle/coordinate_system.png (https://raw.githubusercontent.com/AshishKingdom/OpenGL-Tutorials/gh-pages/images/first-triangle/coordinate_system.png) A first good tutorial is that of Ashish at this web address https://ashishkingdom.github.io/OpenGL-Tutorials/ (https://ashishkingdom.github.io/OpenGL-Tutorials/)
A short answer is change the 2nd vertex2f from 0,0 to 0,1 (vertex2f x,y)
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: AndyA on April 13, 2021, 07:25:59 pm
Yep, that's what I was trying to figure out. It's just like the X/Y axis I learned in school vs. the computer screen coordinates.
Thanks for the solution and the link to Ashish's OpenGL tutorial page.
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: bplus on April 14, 2021, 01:51:11 pm
It would be nice to work with any 3 given points (that fit on screen) and any 3 colors for a Rosetta post.
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: TempodiBasic on April 15, 2021, 06:11:57 pm
the first is simpler make at random the 3 vertex cohordinates in the range of -1 to +1 for the X and Y make at random the RGBA components of color in the range of 0 to +1 (0-255) and you got it as here
the second way is to port the GL part of code from this demo in which I use a very fine your program to show the other two graphic output : normal or starndard graphic an the OpenGl graphic while in your original work you have greatly mastered the Maptriangles mode. https://www.qb64.org/forum/index.php?topic=3334.msg126287#msg126287 (https://www.qb64.org/forum/index.php?topic=3334.msg126287#msg126287)
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: bplus on April 15, 2021, 07:16:14 pm
@TempodiBasic Good changes! Could the switching to a new triangle be smoothed out maybe with _delay or _limit?
Title: Re: Triangle multicolored in OpenGl (Rosetta code)
Post by: TempodiBasic on April 16, 2021, 03:59:57 am
@bplus you're right! Using _delay can do a smoother changing of the aspect of the triangle! here a way to get this: