2d maximum productivity ?

Prompt please as with the OpenGL it is possible to get the maximum productivity in 2d for example video output?

glDrawPixels or there is still any function?

Use textures with “2D” polygons (basically, render flat 3d surfaces parallel to the display).

Thanks Zengar.

Also disable lighting, depth, stencil, blending … if you dont need them.

Excuse me for a question I only a few days with OpenGL…
“glBegin (GL_QUADS)” it is a polygon?
How to me on it to put texture? “glTexCoord2f”?

glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();

================================
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;

for i:=0 to 5125124 do bitmp[i]:= random(255) ;

glTexImage2D(GL_TEXTURE_2D, 0, GL_UNSIGNED_BYTE, 512, 512,
0, GL_RGB, GL_UNSIGNED_BYTE, @bitmp);

glEnable(GL_TEXTURE_2D);

glBegin(GL_QUADS);

glTexCoord2f(0,0);
glVertex3f(-10.0, 10.0, 0.0);
glTexCoord2f(0,1);
glVertex3f( 10.0, 10.0, 0.0);
glTexCoord2f(1,1);
glVertex3f( 10.0,-10.0, 0.0);
glTexCoord2f(1,0);
glVertex3f(-10.0,-10.0, 0.0);
glEnd();

I see only one white square without a texture?

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,created_texture_id);


  glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

By default, GL_TEXTURE_MIN_FILTER is set to GL_LINEAR_MIPMAP_LINEAR, therefore your texture needs mipmaps. If you don’t specity all of them, then result of using such texture is undefined (usually it doesn’t appear, which is what happened in your case).

Since you do not need mipmaps, you should just disable them by setting MIN and MAX filters to GL_LINEAR or GL_NEAREST. When mapping a textured quad to screen at 1:1 ratio, GL_NEAREST is the best choice.
When you need smooth scaling, use GL_LINEAR - will work for smooth zooming and downscaling up to 2 times. More than that will require mipmaps to get good results.

Thanks k_szczech for the help now everything is all right.

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

But function:
glTexImage2d(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_BYTE, Data);
takes away too many resources?

do not upload texture data each frame. create it once and reuse it with glBindTexture.

GLuint id;
glGenTexture(GL_TEXTURE_2D,&id);
glBindTexture(GL_TEXTURE_2D,id);
glTexImage2D(…);

// per frame:
glBindTexture(GL_TEXTURE_2D,id);
drawQuad();

But if each frame the new picture is necessary to me(for example video)?

then use glTexSubImage2d

Yes, if you’re displaying a video, then you need to update texture each frame.
Still you can optimize it :slight_smile:

On application startup create a texture (glGenTextures / glBindTexture / glTexImage2D / glTexParameter).

For each displayed frame you only need to update contents of texture (no need to create it again).
For this use glTexSubImage2D.

The difference is, that glTexImage2D creates new texture and glTexSubImage2D only replaces contents of existing texture and you can use it to quickly replace entire texture image.

Texture format is also important. GL_BGR will probably work faster than GL_RGB.

For better upload parallelism, use pixel buffer object extension.