--- a/hedgewars/uRender.pas Sun Jun 15 04:46:34 2014 +0200
+++ b/hedgewars/uRender.pas Sun Jun 15 13:42:34 2014 +0200
@@ -76,6 +76,9 @@
// TODO everything below this should not need a public interface
+procedure CreateFramebuffer(var frame, depth, tex: GLuint);
+procedure DeleteFramebuffer(var frame, depth, tex: GLuint);
+
procedure EnableTexture(enable:Boolean);
procedure SetTexCoordPointer(p: Pointer;n: Integer);
@@ -96,7 +99,8 @@
implementation
uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uVariables, uUtils, uConsts
- {$IFDEF GL2}, uMatrix, uConsole{$ENDIF};
+ {$IFDEF GL2}, uMatrix, uConsole{$ENDIF}
+ {$IF NOT DEFINED(SDL2) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF};
{$IFDEF USE_TOUCH_INTERFACE}
const
@@ -246,6 +250,53 @@
end;
{$ENDIF}
+function glLoadExtension(extension : shortstring) : boolean;
+begin
+//TODO: pas2c does not handle {$IF (GLunit = gles11) OR DEFINED(PAS2C)}
+{$IFNDEF PAS2C}
+{$IF GLunit = gles11}
+ // FreePascal doesnt come with OpenGL ES 1.1 Extension headers
+ extension:= extension; // avoid hint
+ glLoadExtension:= false;
+ AddFileLog('OpenGL - "' + extension + '" skipped')
+{$ELSE}
+ glLoadExtension:= glext_LoadExtension(extension);
+ if glLoadExtension then
+ AddFileLog('OpenGL - "' + extension + '" loaded')
+ else
+ AddFileLog('OpenGL - "' + extension + '" failed to load');
+{$ENDIF}
+
+{$ELSE} // pas2c part
+ glLoadExtension:= false;
+{$ENDIF}
+end;
+
+{$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)}
+procedure CreateFramebuffer(var frame, depth, tex: GLuint);
+begin
+ glGenFramebuffersEXT(1, @frame);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame);
+ glGenRenderbuffersEXT(1, @depth);
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth);
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth);
+ glGenTextures(1, @tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);
+end;
+
+procedure DeleteFramebuffer(var frame, depth, tex: GLuint);
+begin
+ glDeleteTextures(1, @tex);
+ glDeleteRenderbuffersEXT(1, @depth);
+ glDeleteFramebuffersEXT(1, @frame);
+end;
+
+{$ENDIF}
procedure RenderSetup();
var AuxBufNum: LongInt = 0;
tmpstr: ansistring;
--- a/hedgewars/uStore.pas Sun Jun 15 04:46:34 2014 +0200
+++ b/hedgewars/uStore.pas Sun Jun 15 13:42:34 2014 +0200
@@ -489,31 +489,6 @@
IMG_Quit();
end;
-{$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)}
-procedure CreateFramebuffer(var frame, depth, tex: GLuint);
-begin
- glGenFramebuffersEXT(1, @frame);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame);
- glGenRenderbuffersEXT(1, @depth);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth);
- glGenTextures(1, @tex);
- glBindTexture(GL_TEXTURE_2D, tex);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0);
-end;
-
-procedure DeleteFramebuffer(var frame, depth, tex: GLuint);
-begin
- glDeleteTextures(1, @tex);
- glDeleteRenderbuffersEXT(1, @depth);
- glDeleteFramebuffersEXT(1, @frame);
-end;
-{$ENDIF}
-
procedure StoreRelease(reload: boolean);
var ii: TSprite;
ai: TAmmoType;
@@ -743,28 +718,6 @@
end;
end;
-function glLoadExtension(extension : shortstring) : boolean;
-begin
-//TODO: pas2c does not handle {$IF (GLunit = gles11) OR DEFINED(PAS2C)}
-{$IFNDEF PAS2C}
-{$IF GLunit = gles11}
- // FreePascal doesnt come with OpenGL ES 1.1 Extension headers
- extension:= extension; // avoid hint
- glLoadExtension:= false;
- AddFileLog('OpenGL - "' + extension + '" skipped')
-{$ELSE}
- glLoadExtension:= glext_LoadExtension(extension);
- if glLoadExtension then
- AddFileLog('OpenGL - "' + extension + '" loaded')
- else
- AddFileLog('OpenGL - "' + extension + '" failed to load');
-{$ENDIF}
-
-{$ELSE} // pas2c part
- glLoadExtension:= false;
-{$ENDIF}
-end;
-
procedure SetupOpenGLAttributes;
begin
{$IFDEF IPHONEOS}
@@ -1093,7 +1046,7 @@
glutHideWindow();
// we do not need to set this callback, but it is required for GLUT3 compat
glutDisplayFunc(@SwapBuffers);
- SetupRenderer();
+ RenderSetup();
end;
{$ENDIF} // SDL2
{$ENDIF} // USE_VIDEO_RECORDING
--- a/hedgewars/uVideoRec.pas Sun Jun 15 04:46:34 2014 +0200
+++ b/hedgewars/uVideoRec.pas Sun Jun 15 13:42:34 2014 +0200
@@ -48,7 +48,7 @@
procedure freeModule;
implementation
-uses uVariables, uUtils, GLunit, SDLh, SysUtils, uIO, uMisc, uTypes;
+uses uVariables, uUtils, GLunit, SDLh, SysUtils, uIO, uMisc, uTypes, uDebug;
type TAddFileLogRaw = procedure (s: pchar); cdecl;
const AvwrapperLibName = 'libavwrapper';
@@ -109,15 +109,16 @@
filename:= UserPathPrefix + '/VideoTemp/' + RecPrefix;
soundFilePath:= UserPathPrefix + '/VideoTemp/' + RecPrefix + '.sw';
- if AVWrapper_Init(@AddFileLogRaw
+ TryDo(AVWrapper_Init(@AddFileLogRaw
, PChar(ansistring(filename))
, PChar(ansistring(desc))
, PChar(ansistring(soundFilePath))
, PChar(ansistring(cAVFormat))
, PChar(ansistring(cVideoCodec))
, PChar(ansistring(cAudioCodec))
- , cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality) < 0 then
- halt(HaltFatalError);
+ , cScreenWidth, cScreenHeight, cVideoFramerateNum, cVideoFramerateDen, cVideoQuality) >= 0,
+ 'AVWrapper_Init failed',
+ true);
numPixels:= cScreenWidth*cScreenHeight;
YCbCr_Planes[0]:= GetMem(numPixels);