Drawing a point using OpenGL, but not in immediate mode

So, I would like to draw a 2D point in OpenGL, but not in immediate mode. It has been a while since I programmed in OpenGL, so I'm a little rusty and I can not find it in Redbook.

All help is appreciated.

Thank!

+3
source share
2 answers

If "not in immediate mode" you want to load your geometry onto a graphics card and make calls to render it, then there are several ways to do this. The simplest is to use a display list to precompile the list of OpenGL commands to execute

Gluint list = glGenLists(1);
// Release with glDeleteLists(list,1);
glNewList(list,GL_COMPILE);

// Drawing code here

glEndList();

Then visualize it with

glCallList(list);

( , GLEW). VBO, OpenGL:

float data[2] = {...};

GLuint buffer;
glGenBuffersARB(1,&buffer);
// Release with glDeleteBuffersARB(1,&buffer);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data, GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);

-

GLuint indices[] = {0};

glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer);
glVertexPointer(3, GL_FLOAT, sizeof(float)*2, ((GLubyte*)NULL)+0);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_POINTS,sizeof(indices)/(sizeof(indices[0])),GL_UNSIGNED_INT,indices);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);    

( ). , , .

, , ( 10 100 , ) , .

+4

, ... , - glBegin (GL_POINTS);

, , - ...

? ?

-3

Source: https://habr.com/ru/post/1728775/


All Articles