0
\$\begingroup\$
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "glut.h"

//initilization of funtion
void init(void) {
    glClearColor(0.0, 0.0, 0.0, 1.0);
}

//function to draw
void display(void) {

    //delear: 6 points array
    static const GLfloat vtx2[] = { -0.8f,0.6f,0.0f,0.7f,-0.8f,-0.6f,0.8f,0.6f,0.0f,-0.7f,0.8f,-0.6f };

    
    glClear(GL_COLOR_BUFFER_BIT);

    glColor3b(0.1, 0.8, 0.1);
    glPointSize(10.0);
    glVertexPointer(2, GL_FLOAT, 0, vtx2);
    glEnableClientState(GL_VERTEX_ARRAY);
    glDrawArrays(GL_POINTS, 0, 6);
    glDisableClientState(GL_VERTEX_ARRAY);

    glFlush();//execution
}

//main function
int main(int argc, char* argv[]) {
    //GLUT library initialization
    glutInit(&argc, argv);
    //setup dispalying mode
    glutInitDisplayMode(GLUT_RGBA);
    //creat window
    glutCreateWindow(argv[0]);
    //sign function to draw
    glutDisplayFunc(display);
    //Intilaization
    init();
    //main loop
    glutMainLoop();

    return EXIT_SUCCESS;
}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ What is your OpenGL version? Your code looks a bit old. Some features are deprecated in modern OpenGL such as glEnableClientState. \$\endgroup\$
    – Mangata
    May 11, 2022 at 6:36

1 Answer 1

1
\$\begingroup\$

glColor3b specifies colour as 3 signed bytes, but you are passing float values. These float values will be all rounded down to 0, which is black, the same as your clear colour.

If you want to specify colour as floats, use glColor3f.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .