Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I draw a grid of squares the size of a fraction of the screen in opengl?
    text
    copied!<p>I have the whole screen ( I may make the area smaller than the window size eventually, maybe to show scores and other relevant stats? I'm probably far from that point though ). I want to draw a grid of squares.</p> <p>The size of these squares should be a certain fraction of the size of the screen, eg. 1/2, 1/3, 1/9, etc.</p> <p>I am passing an int that starts at 2, which will help me end up with a 2x2 grid of coloured squares. After certain conditions are met, this int will increment by 1, and I'll end up with a grid 3x3, 4x4 etc. ( You shouldn't worry about any actual 'game logic', I'll try to figure that out myself :P )</p> <p>What I'm finding confusing, is the whole -1.0 to +1.0 coordinates opengl uses ( I hope I haven't gotten this completely wrong XD) . I have basic knowledge in SDL, and so I'm used to using 0 to 'screen height/width' coordinates. However, I don't think SDL's graphics is suitable for what I want to try, so I'm attempting to use opengl with SDL.</p> <p>How might I go about figuring out the coordinates and dimensions for these squares, and actually drawing them?</p> <p>( I'm not going to post any code, because I doubt what I have so far will help, but this is inside a single function that does all drawing )</p> <p>extra : If any of you know how to turn coordinates that look like (x=32, y=128), for example, into opengl's floats, that might make life a whole lot easier for me, and I could figure out the coordinates, dimensions and drawing myself. (Yes, I know that opengl goes from -1.0 to +1.0 no matter the window size, so something like this wouldn't scale, but I'm perfectly fine with that)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload