![]() This is how OpenGL handles screen coordinates: But anyway, you may have also wondered how we specify where on the screen our vertices are? Why not use double? Basically because GPUs still prefer to use floats – and doubles might slow things down because of conversions and all. We’ll have to define each corner, or vertex.įor now, we’ll do this by making an array of twelve floats – three values for each vertex. First of all though, we need to define the triangle that we want to draw. If not, then also great – OpenGL’s interface just functions similarly to one. If you’ve used a C-like language before, great. I’ll explain how OpenGL works as we go along. You can call those methods whatever you like. We’ll also want two new methods – one for setting up the triangle we want to draw (which we’ll call within run(), right before our loop), and then another one which will actually draw it to the screen (which we’ll have to call every iteration of our loop). ![]() We want to implement the Runnable interface, and therefore make a method run() in our class. Today, we’re going to make it a bit more interesting by using OpenGL to draw a triangle on it! Before we do that though, there are a few small changes that we have to make to our class. So, last time we managed to create an amazing blank window.
0 Comments
Leave a Reply. |