74 |
74 |
75 procedure RenderSetup(); |
75 procedure RenderSetup(); |
76 |
76 |
77 // TODO everything below this should not need a public interface |
77 // TODO everything below this should not need a public interface |
78 |
78 |
|
79 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
|
80 procedure DeleteFramebuffer(var frame, depth, tex: GLuint); |
|
81 |
79 procedure EnableTexture(enable:Boolean); |
82 procedure EnableTexture(enable:Boolean); |
80 |
83 |
81 procedure SetTexCoordPointer(p: Pointer;n: Integer); |
84 procedure SetTexCoordPointer(p: Pointer;n: Integer); |
82 procedure SetVertexPointer(p: Pointer;n: Integer); |
85 procedure SetVertexPointer(p: Pointer;n: Integer); |
83 procedure SetColorPointer(p: Pointer;n: Integer); |
86 procedure SetColorPointer(p: Pointer;n: Integer); |
94 procedure openglTint (r, g, b, a: Byte); inline; |
97 procedure openglTint (r, g, b, a: Byte); inline; |
95 |
98 |
96 |
99 |
97 implementation |
100 implementation |
98 uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uVariables, uUtils, uConsts |
101 uses {$IFNDEF PAS2C} StrUtils, {$ENDIF}SysUtils, uVariables, uUtils, uConsts |
99 {$IFDEF GL2}, uMatrix, uConsole{$ENDIF}; |
102 {$IFDEF GL2}, uMatrix, uConsole{$ENDIF} |
|
103 {$IF NOT DEFINED(SDL2) AND DEFINED(USE_VIDEO_RECORDING)}, glut {$ENDIF}; |
100 |
104 |
101 {$IFDEF USE_TOUCH_INTERFACE} |
105 {$IFDEF USE_TOUCH_INTERFACE} |
102 const |
106 const |
103 FADE_ANIM_TIME = 500; |
107 FADE_ANIM_TIME = 500; |
104 MOVE_ANIM_TIME = 500; |
108 MOVE_ANIM_TIME = 500; |
244 |
248 |
245 CompileProgram:= program_; |
249 CompileProgram:= program_; |
246 end; |
250 end; |
247 {$ENDIF} |
251 {$ENDIF} |
248 |
252 |
|
253 function glLoadExtension(extension : shortstring) : boolean; |
|
254 begin |
|
255 //TODO: pas2c does not handle {$IF (GLunit = gles11) OR DEFINED(PAS2C)} |
|
256 {$IFNDEF PAS2C} |
|
257 {$IF GLunit = gles11} |
|
258 // FreePascal doesnt come with OpenGL ES 1.1 Extension headers |
|
259 extension:= extension; // avoid hint |
|
260 glLoadExtension:= false; |
|
261 AddFileLog('OpenGL - "' + extension + '" skipped') |
|
262 {$ELSE} |
|
263 glLoadExtension:= glext_LoadExtension(extension); |
|
264 if glLoadExtension then |
|
265 AddFileLog('OpenGL - "' + extension + '" loaded') |
|
266 else |
|
267 AddFileLog('OpenGL - "' + extension + '" failed to load'); |
|
268 {$ENDIF} |
|
269 |
|
270 {$ELSE} // pas2c part |
|
271 glLoadExtension:= false; |
|
272 {$ENDIF} |
|
273 end; |
|
274 |
|
275 {$IF DEFINED(USE_S3D_RENDERING) OR DEFINED(USE_VIDEO_RECORDING)} |
|
276 procedure CreateFramebuffer(var frame, depth, tex: GLuint); |
|
277 begin |
|
278 glGenFramebuffersEXT(1, @frame); |
|
279 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frame); |
|
280 glGenRenderbuffersEXT(1, @depth); |
|
281 glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth); |
|
282 glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight); |
|
283 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth); |
|
284 glGenTextures(1, @tex); |
|
285 glBindTexture(GL_TEXTURE_2D, tex); |
|
286 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil); |
|
287 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
288 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
289 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0); |
|
290 end; |
|
291 |
|
292 procedure DeleteFramebuffer(var frame, depth, tex: GLuint); |
|
293 begin |
|
294 glDeleteTextures(1, @tex); |
|
295 glDeleteRenderbuffersEXT(1, @depth); |
|
296 glDeleteFramebuffersEXT(1, @frame); |
|
297 end; |
|
298 |
|
299 {$ENDIF} |
249 procedure RenderSetup(); |
300 procedure RenderSetup(); |
250 var AuxBufNum: LongInt = 0; |
301 var AuxBufNum: LongInt = 0; |
251 tmpstr: ansistring; |
302 tmpstr: ansistring; |
252 tmpint: LongInt; |
303 tmpint: LongInt; |
253 tmpn: LongInt; |
304 tmpn: LongInt; |