hedgewars/uRender.pas
branchqmlfrontend
changeset 11833 a69124eb7ce7
parent 11408 b894922d58cc
parent 11829 3f1f8f79fcdb
child 12860 1b2b84315d27
equal deleted inserted replaced
11832:8c71c5a1172f 11833:a69124eb7ce7
   101 procedure openglPopMatrix       (); inline;
   101 procedure openglPopMatrix       (); inline;
   102 procedure openglTranslatef      (X, Y, Z: GLfloat); inline;
   102 procedure openglTranslatef      (X, Y, Z: GLfloat); inline;
   103 
   103 
   104 
   104 
   105 implementation
   105 implementation
   106 uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uVariables, uUtils, uConsts
   106 uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}uVariables, uUtils, uConsts
   107      {$IFDEF GL2}, uMatrix, uConsole{$ENDIF};
   107      {$IFDEF GL2}, uMatrix, uConsole{$ENDIF}, uPhysFSLayer, uDebug;
   108 
   108 
   109 {$IFDEF USE_TOUCH_INTERFACE}
   109 {$IFDEF USE_TOUCH_INTERFACE}
   110 const
   110 const
   111     FADE_ANIM_TIME = 500;
   111     FADE_ANIM_TIME = 500;
   112     MOVE_ANIM_TIME = 500;
   112     MOVE_ANIM_TIME = 500;
   254 
   254 
   255 {$IFDEF GL2}
   255 {$IFDEF GL2}
   256 function CompileShader(shaderFile: string; shaderType: GLenum): GLuint;
   256 function CompileShader(shaderFile: string; shaderType: GLenum): GLuint;
   257 var
   257 var
   258     shader: GLuint;
   258     shader: GLuint;
   259     f: Textfile;
   259     f: PFSFile;
   260     source, line: AnsiString;
   260     source, line: ansistring;
   261     sourceA: Pchar;
   261     sourceA: Pchar;
   262     lengthA: GLint;
   262     lengthA: GLint;
   263     compileResult: GLint;
   263     compileResult: GLint;
   264     logLength: GLint;
   264     logLength: GLint;
   265     log: PChar;
   265     log: PChar;
   266 begin
   266 begin
   267     Assign(f, PathPrefix + cPathz[ptShaders] + '/' + shaderFile);
   267     f:= pfsOpenRead(cPathz[ptShaders] + '/' + shaderFile);
   268     filemode:= 0; // readonly
   268     checkFails(f <> nil, 'Unable to load ' + shaderFile, true);
   269     Reset(f);
       
   270     if IOResult <> 0 then
       
   271     begin
       
   272         AddFileLog('Unable to load ' + shaderFile);
       
   273         halt(HaltStartupError);
       
   274     end;
       
   275 
   269 
   276     source:='';
   270     source:='';
   277     while not eof(f) do
   271     while not pfsEof(f) do
   278     begin
   272     begin
   279         ReadLn(f, line);
   273         pfsReadLnA(f, line);
   280         source:= source + line + #10;
   274         source:= source + line + #10;
   281     end;
   275     end;
   282 
   276 
   283     Close(f);
   277     pfsClose(f);
   284 
   278 
   285     WriteLnToConsole('Compiling shader: ' + PathPrefix + cPathz[ptShaders] + '/' + shaderFile);
   279     WriteLnToConsole('Compiling shader: ' + cPathz[ptShaders] + '/' + shaderFile);
   286 
   280 
   287     sourceA:=PChar(source);
   281     sourceA:=PChar(source);
   288     lengthA:=Length(source);
   282     lengthA:=Length(source);
   289 
   283 
   290     shader:=glCreateShader(shaderType);
   284     shader:=glCreateShader(shaderType);
   466 
   460 
   467     repeat
   461     repeat
   468         begin
   462         begin
   469         // print up to 3 extentions per row
   463         // print up to 3 extentions per row
   470         // ExtractWord will return empty string if index out of range
   464         // ExtractWord will return empty string if index out of range
   471         AddFileLog(TrimRight(
   465         //AddFileLog(TrimRight(
       
   466         AddFileLog(Trim(
   472             ExtractWord(tmpint, tmpstr, [' ']) + ' ' +
   467             ExtractWord(tmpint, tmpstr, [' ']) + ' ' +
   473             ExtractWord(tmpint+1, tmpstr, [' ']) + ' ' +
   468             ExtractWord(tmpint+1, tmpstr, [' ']) + ' ' +
   474             ExtractWord(tmpint+2, tmpstr, [' '])
   469             ExtractWord(tmpint+2, tmpstr, [' '])
   475         ));
   470         ));
   476         tmpint := tmpint + 3;
   471         tmpint := tmpint + 3;
   506 {$ENDIF}
   501 {$ENDIF}
   507 
   502 
   508 {$IFDEF GL2}
   503 {$IFDEF GL2}
   509 
   504 
   510 {$IFDEF PAS2C}
   505 {$IFDEF PAS2C}
   511     err := glewInit();
   506     if glewInit() <> GLEW_OK then
   512     if err <> GLEW_OK then
       
   513         begin
   507         begin
   514         WriteLnToConsole('Failed to initialize GLEW.');
   508         WriteLnToConsole('Failed to initialize GLEW.');
   515         halt(HaltStartupError);
   509         halt(HaltStartupError);
   516         end;
   510         end;
   517 {$ENDIF}
   511 {$ENDIF}