#include <GL/glew.h>
#include <freeglut.h>
#include <iostream>
struct Vec3 {
float x, y, z;
Vec3() {}
Vec3(float _x, float _y, float _z) {
x = _x;
y = _y;
z = _z;
}
};
GLuint VBO;
static void RenderScene() {
glClear(GL_COLOR_BUFFER_BIT);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
// void glDrawArrays(GLenum mode, GLint first, GLsizei count);
glDrawArrays(GL_POINTS, 0, 1);
glDisableVertexAttribArray(0);
glutSwapBuffers();
}
static void CreateVertexBuffer() {
Vec3 Vertices[1];
Vertices[0] = Vec3(0.0f, 0.0f, 0.0f);
glGenBuffers(1, &VBO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
int width = 800;
int height = 600;
glutInitWindowSize(width, height);
int win = glutCreateWindow("freeglut - glutCreateWindow() - Draw Dot");
GLenum res = glewInit();
if (res != GLEW_OK) {
std::cout << glewGetErrorString(res);
return 1;
}
GLclampf Red = 0.0f, Green = 0.0f, Blue = 0.0f, Alpha = 0.0f;
glClearColor(Red, Green, Blue, Alpha);
CreateVertexBuffer();
glutDisplayFunc(RenderScene);
glutMainLoop();
}
/*
run
*/