Color class for WebGL | Sololearn: Learn to code for FREE!


Color class for WebGL

I started learning WebGL and there are no colors available by default so I am making Color class but I cant decide how to represent it. If I make normal class with properties it will be easy to handle but creation of object is slower Or I could make class with only static methods and represent color as array of red blue green, it would be faster to initialize What do you think?

1/19/2022 4:05:23 PM

David Dolejší

6 Answers

New Answer


D Doyen Thanks for answers anyway, I try them both and will see. If you know canvas, I am working on little WebGL library which will work similar to canvas2d API cause well WebGL is faster.


I wud also recommend that you should try both of the approach and find the optimal one


Sorry if this might not be the answer you expect Most people don't do webGl So I recommend that you do a little more research on your subject


But heavyweight


According to my research it more heavy than canvas and the learning curve is more steep


Ok I think I didn't understand you, you wanna make a class to be able to use 0-255, instead of 0-1, color don't you? If I were you, I just used colorValue/255, but I think you mean something else 😅😅😅 Anyway, to answer your question, I prefer to have a faster initialization as a viewer; that's because I don't see your programming method as a user, I just want a program that works and loads fast!