-1

I'm trying to make a player in OpenGL. I use ffmpeg to decode the video.

I searched several tutorial (StackOverflow, ....) how to convert my pFrameRGB-> data [0] texture in OpenGL, but it still shows me a white square. I converted my video to 512x256 to comply with 2 ^ n.

I know my pFrameRGB is correct because I can create frameX.ppm with "SaveFrame (...)" function.

I used the following source ( https://github.com/arashafiei/dranger-ffmpeg-tuto/blob/master/tutorial02.c ) code as a model by adapting for my player.

And this is my source code:

http://www.sourcepod.com/uagkel22-19078

Does one of you have a solution to my problem?

Edit 1:

I delete:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 1 ? GL_REPEAT : GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 1 ? GL_REPEAT : GL_CLAMP );

And replaced:

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, pCodecCtx->width, pCodecCtx->height, 0, GL_RGB, GL_UNSIGNED_BYTE, pFrameRGB->data[0]);

by:

if(firstRendering){
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, pCodecCtx->width, pCodecCtx->height, 0, GL_RGB, GL_UNSIGNED_BYTE, pFrameRGB->data[0]);

firstRendering = 0;

}else{

glActiveTexture(texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, pCodecCtx->width, pCodecCtx->height, GL_RGB, GL_UNSIGNED_BYTE, pFrameRGB->data[0]);
}

And i try to run but stiil nothing...

genpfault
  • 51,148
  • 11
  • 85
  • 139
2kPi
  • 1
  • 2

1 Answers1

0

In your source code you have these lines:

glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, 1 ? GL_REPEAT : GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, 1 ? GL_REPEAT : GL_CLAMP );

First of all, the values you want to set are integers, so you have to use glTexParameteri (note the i at the end).

Second, first you disable mipmapping, then you try to reenable it. If you want to mipmap, you must supply a full image pyramid (within the selected LoD range). For a video player you normally want to disable mipmapping:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

I converted my video to 512x256 to comply with 2 ^ n.

No need to, as of OpenGL-2. Since that version texture images may be of arbitrary dimension.

Also instead of passing the video frames into glTexImage2D, which does a full texture object initialization, I suggest you use glTexSubImage2D which just replaces the image data. You must call glTexImage2D once, before the first call to glTexSubImage2D, with the right format parameters; pass a null pointer to data to initialize the texture without setting the data.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • I replace my code according to your advice but still nothing... What wrong with my code... – 2kPi Jun 12 '13 at 10:56
  • @2kPi: Only way to tell: Litter that thing with lots and lots of error checking and diagnostic logging prints. – datenwolf Jun 12 '13 at 11:18