• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# [Solved][NEWBIE]How to get a round point, not square?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

7 replies to this topic

### #1zerony  Members

Posted 05 November 2007 - 04:54 AM

http://www.gamedev.net/community/forums/topic.asp?topic_id=333237
but I am not lucky, I can not figure out how I can get a round point with a big glPointSize(5). Here is another piece of code:
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_NOTEQUAL, 0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);

glPointSize( 5.0);
glColor4f(1.0, 1.0, 0.0, 1.0);
for (int i=0; i < dotCount; i++)
{
glBegin(GL_POINTS);
glVertex2f(dot[i].x, dot[i].y);
glEnd();
}
glColor4f(1.0, 1.0, 1.0, 1.0);

glDisable(GL_POINT_SMOOTH);
glBlendFunc(GL_NONE, GL_NONE);
glDisable(GL_BLEND);
I get from http://paste.lisp.org/display/40834.
The point is still square, not round.
How can I fix the problem? Thanks.

[Edited by - zerony on November 8, 2007 1:33:26 PM]

### #2swiftcoder  Senior Moderators

Posted 05 November 2007 - 05:05 AM

Quote:
 Original post by zeronyThe point is still square, not round.How can I fix the problem? Thanks.

Points are square, no way around that. You can however apply a texture to the point, and if your texture has an alpha channel, and you have blending setup, you can apply whatever shape you want to the point (i.e. the shape represented by the alpha channel).

### #3ramearess  Members

Posted 05 November 2007 - 05:43 AM

To my knowledge there is no such thing as curves in OpenGL if you want something to appear round you have to make it out of small squares, the same way you have to make a circle out of lots of straight lines.

If you want a round dot try GL_POLYGON


#include <cmath.h> //may be <cmath>
#include <gl/gl.h>

//nov = number of vertex
void Dot(int nov, float r){

if (nov < 4) nov = 4;
if (nov > 360) nov = 360;

float angle = (360/nov)*(3.142159/180);
float x[360] = 0, y[360] = 0;

for (int i = 0; i < nov; i++){
x[i] = cosf(r*cosf(i*angle);
y[i] = sinf(r*sinf(i*angle);

glBegin(GL_POLYGON);
for (int i = 0; i < nov; i++){
vertex2f(x[i],y[i]);
}
glEnd();
}



I got a bit bored and thought I'd refresh some OpenGL if your really luck the above function will draw a dot for you.

### #4Brother Bob  Moderators

Posted 05 November 2007 - 05:51 AM

The specification requires that points are rasterized as circles when point smooth is enabled. The code provided does work as it is. If it doesn't, there's something else in another part or the whole program messing with point rendering, or a driver bug.

### #5zerony  Members

Posted 05 November 2007 - 10:57 AM

Quote:
 Original post by Brother Bob The specification requires that points are rasterized as circles when point smooth is enabled. The code provided does work as it is. If it doesn't, there's something else in another part or the whole program messing with point rendering, or a driver bug.

I am pretty new to OPENGL. Here is my code, apapted from opengl example c codes.

#include <GL/glut.h>
#include <stdlib.h>

GLfloat points[3][3] = {
{ -1.0, -1.0, 0.0}, { 0.0, 0.0, 0.0},
{1.0, 1.0, 0.0}};

void init(void)
{
}

void display(void)
{
int i;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
/* The following code displays the control points as dots. */
glPointSize(8.0);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_NOTEQUAL, 0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glBegin(GL_POINTS);
for (i = 0; i < 3; i++)
glVertex3fv(&points[i][0]);
glEnd();

glDisable(GL_POINT_SMOOTH);
glBlendFunc(GL_NONE, GL_NONE);
glDisable(GL_BLEND);
glFlush();
}

void reshape(int w, int h)
{
glViewport(0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
if (w <= h)
glOrtho(-5.0, 5.0, -5.0*(GLfloat)h/(GLfloat)w,
5.0*(GLfloat)h/(GLfloat)w, -5.0, 5.0);
else
glOrtho(-5.0*(GLfloat)w/(GLfloat)h,
5.0*(GLfloat)w/(GLfloat)h, -5.0, 5.0, -5.0, 5.0);
glMatrixMode(GL_MODELVIEW);
}

void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc (keyboard);
glutMainLoop();
return 0;
}

Could you help me make this working for rendering round dots? appreciate your help.

### #6Brother Bob  Moderators

Posted 05 November 2007 - 01:02 PM

That exact code gives me three round dots. If you get something else, I suggest you try update the drivers for your graphics card.

### #7zerony  Members

Posted 05 November 2007 - 02:05 PM

Quote:
 Original post by Brother BobThat exact code gives me three round dots. If you get something else, I suggest you try update the drivers for your graphics card.

Now I just test it on linux box with ati video Card, because I have not get windows box ready yet.
[updated]The code also gives me 3 red round dots on a linux box with NVIDIA Card.
Could you tell me what platform you use? Thanks.

[Edited by - zerony on November 5, 2007 8:05:54 PM]

### #8Brother Bob  Moderators

Posted 05 November 2007 - 08:19 PM

Windows Vista using graphics card from both NVidia and ATI, and also the default software implementation and Mesa gives me the same result.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.