More bumb questions

First - the "socketpair / fork " concept is finally working.
Many thanks to this forum.

Now for dumb questions

  1. Is there a generic description HOW to implement OpenGL to perform a single task ?
    This is what I got so far - in pseudo code - example draw circle :
    draw ( circle )
    define local variables
    clear buffer
    select rendering color, size etc.
    begin (loop)
    process
    end loop
    flush buffer

  2. Related to the above
    If I have a string of tasks/ functions - I assume I woudl clear the buffer once and “flush” after last function.

Now the final one - what did I missed to “see” my circle in this function ?
The function is executed in "idle event " callback.
My “text” rendering function works , but OpenGL_Circle is no show.

 void OpenGL_Circle(void) {
	GLfloat x, y, angle;
	glPointSize(5); // GLfloat size);
	glClear( GL_COLOR_BUFFER_BIT);
	glColor3f(1.0, 1.0, 0.0);
	glBegin( GL_POINTS);
	for (angle = 0.0f; angle <= (2.0f * GL_PI); angle += 0.01f) {
		x = 50.0f * sin(angle);
		y = 50.0f * cos(angle);
		glVertex3f(x, y, 0.0f);
	}
	glEnd();
	//glFlush();   no display 
	glutSwapBuffers();    no display either 
}

Addendum:
I gave ditched the void OpenGL_Circle(void), now using different function and it “shows”.
Of course now I have a new issue .
I want to use my new “draw circle” to draw multiple circles of different size and color.
I can draw two of them, but have not figured out how to code it so they have DIFFERENT “line size” and color.

Here is what I have

void OpenGL_DrawCircle(float size, float red, float green,float blue ,
		float cx, float cy, float r, int num_segments) {
	static int flag = 0;
	glPointSize(2.0); // no change only for point size
	//glClearColor(0.4, 0.4, 0.4, 0.4);  // sets background to greiish
	// clear on first usage only
if( flag == 0 )
{
	glClear(GL_COLOR_BUFFER_BIT);
    flag++;
}
	glLineWidth( 5.0); 	//GLfloat width);
	glColor3f(1.0, 0.0, 0.0);
    glBegin(GL_LINE_LOOP);
    for (int ii = 0; ii < num_segments; ii++)   {
        float theta = 2.0f * 3.1415926f * float(ii) / float(num_segments);//get the current angle
        float x = r * cosf(theta);//calculate the x component
        float y = r * sinf(theta);//calculate the y component
        glVertex2f(x + cx, y + cy);//output vertex
    }
    glEnd();
    glFlush();
}

And used this way:

void OpenGL_Smith_Chart(void)
{
	// draw centered outline
	OpenGL_DrawCircle(5.0 , // line width
			1.0, // full red
			0.0, // green
	        0.0, // blue
			0,   // xcentered
			0, // y centered
			0.9, // relative to window diameter
			100  // # of segments (?)
			);


	// draw Z = 0 circle
		OpenGL_DrawCircle(3.0 , // line width
				0.0, // full red
				1.0, // green
		        0.0, // blue
				0.9/2,   // x centered
				0, // y centered
				0.9/2, // relative to window diameter
				100  // # of segments (?)
				);
}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.