3
$\begingroup$

I'm working on an assignment and I need to draw using only GL_POINTS. I realize this is an expensive approach but it's for the homework, so no GL_TRIANGLES / GL_POLYGON / GL_LINES etc.

First, I'm trying to understand the concept of using only points. Say I want to draw a square that's 100 x 100 pixels. Would I need four for-loops drawing 100 pixels each in straight lines to create the square? What if I want to fill the square with color?

I understand drawing a square using GL_POLYGON as that's fairly straight forward. We're using the GLUT library just to draw shapes with points.

$\endgroup$
  • $\begingroup$ Meta discussion about homework questions. $\endgroup$ – trichoplax Sep 23 '15 at 17:23
  • 4
    $\begingroup$ Could you refine your question? You have a nice introduction, but it's difficult to know what you're really asking. How to use GL_POINTS? How to use points to draw a 2D shape? etc.. $\endgroup$ – RichieSams Sep 23 '15 at 18:34
2
$\begingroup$

I reckon your instructor is encouraging you to implement low-level rendering algorithms.

The obstacle to draw shapes using just points is the contradiction between continuous and discrete. Shapes are logically continuous if in its area every pixel is shaded. But you can not draw an actually continuous line using discrete points because infinite points are needed. If you draw points directly in the "world", you can not guarantee every pixel on the screen can be covered after projection, unless you set the interval small enough(which may be of quite low performance).

My advice is to maintain the world coordinates of the vertices of the shape but not draw it. Get the "projected" coordinates on screen and fill the area later using DDA or some other interpolation algorithms. "Projected" is the coordinates obtained by the three matrices(Projection, View, Model), I think you've heard of these. So in the filling process GLUT is used to draw points on the 2D screen, and cover every pixel in the area.

$\endgroup$
  • 1
    $\begingroup$ It might be that he does not need to draw a solid object! Or just draw in a 2d projection screen. $\endgroup$ – joojaa Sep 29 '15 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.