forked from mia/Aegisub
Added error checking routines to GL texture uploading
Originally committed to SVN as r877.
This commit is contained in:
parent
2d1fdcdfb9
commit
304b10b6d5
1 changed files with 8 additions and 0 deletions
|
@ -402,6 +402,7 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
|
||||||
// Set context
|
// Set context
|
||||||
GetGLContext(displayList.front())->SetCurrent(*displayList.front());
|
GetGLContext(displayList.front())->SetCurrent(*displayList.front());
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
if (glGetError() != 0) throw _T("Error enabling texturing.");
|
||||||
|
|
||||||
if (lastTex == 0) {
|
if (lastTex == 0) {
|
||||||
// Enable
|
// Enable
|
||||||
|
@ -409,7 +410,9 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
|
||||||
|
|
||||||
// Generate texture with GL
|
// Generate texture with GL
|
||||||
glGenTextures(1, &lastTex);
|
glGenTextures(1, &lastTex);
|
||||||
|
if (glGetError() != 0) throw _T("Error generating texture.");
|
||||||
glBindTexture(GL_TEXTURE_2D, lastTex);
|
glBindTexture(GL_TEXTURE_2D, lastTex);
|
||||||
|
if (glGetError() != 0) throw _T("Error binding texture.");
|
||||||
|
|
||||||
// Load image data into texture
|
// Load image data into texture
|
||||||
int height = frame.h;
|
int height = frame.h;
|
||||||
|
@ -419,18 +422,23 @@ GLuint VideoContext::GetFrameAsTexture(int n) {
|
||||||
texW = float(frame.w)/float(tw);
|
texW = float(frame.w)/float(tw);
|
||||||
texH = float(frame.h)/float(th);
|
texH = float(frame.h)/float(th);
|
||||||
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,tw,th,0,format,GL_UNSIGNED_BYTE,NULL);
|
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,tw,th,0,format,GL_UNSIGNED_BYTE,NULL);
|
||||||
|
if (glGetError() != 0) throw _T("Error allocating texture.");
|
||||||
|
|
||||||
// Set texture
|
// Set texture
|
||||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||||
|
if (glGetError() != 0) throw _T("Error setting hinting.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load texture data
|
// Load texture data
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,frame.w,frame.h,format,GL_UNSIGNED_BYTE,frame.data[0]);
|
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,frame.w,frame.h,format,GL_UNSIGNED_BYTE,frame.data[0]);
|
||||||
|
if (glGetError() != 0) throw _T("Error uploading primary plane");
|
||||||
|
|
||||||
// UV planes for YV12
|
// UV planes for YV12
|
||||||
if (frame.format == FORMAT_YV12) {
|
if (frame.format == FORMAT_YV12) {
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,0,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[1]);
|
glTexSubImage2D(GL_TEXTURE_2D,0,0,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[1]);
|
||||||
|
if (glGetError() != 0) throw _T("Error uploading U plane.");
|
||||||
glTexSubImage2D(GL_TEXTURE_2D,0,frame.w/2,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[2]);
|
glTexSubImage2D(GL_TEXTURE_2D,0,frame.w/2,frame.h,frame.w/2,frame.h/2,format,GL_UNSIGNED_BYTE,frame.data[2]);
|
||||||
|
if (glGetError() != 0) throw _T("Error uploadinv V plane.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return texture number
|
// Return texture number
|
||||||
|
|
Loading…
Reference in a new issue