Explorar o código

morphos/opengl: fixed glViewport() to work, and added some workarounds for various versions of tinygl.library

Karoly Balogh hai 2 semanas
pai
achega
f0a1d304e0
Modificáronse 2 ficheiros con 19 adicións e 4 borrados
  1. 2 2
      packages/opengl/src/gl.pp
  2. 17 2
      packages/opengl/src/tinygl.inc

+ 2 - 2
packages/opengl/src/gl.pp

@@ -63,7 +63,7 @@ uses
   WinApi.Windows, System.DynLibs
   {$ELSE WinApi.Windows}
   {$IFDEF MorphOS}
-  MorphApi.Tinygl
+  MorphApi.Exec, MorphApi.Tinygl
   {$ELSE MorphOS}
   System.DynLibs
   {$ENDIF MorphOS}
@@ -75,7 +75,7 @@ uses
   Windows, dynlibs
   {$ELSE Windows}
   {$IFDEF MorphOS}
-  TinyGL
+  exec, TinyGL
   {$ELSE MorphOS}
   dynlibs
   {$ENDIF MorphOS}

+ 17 - 2
packages/opengl/src/tinygl.inc

@@ -78,7 +78,12 @@ syscall sysvbase TinyGLBase 232;
 procedure _GLScalef(gcl: pointer; x, y, z: GLfloat);
 syscall sysvbase TinyGLBase 238;
 
-procedure _GLViewPort(gcl: pointer; x, y: GLint; width, height: GLsizei);
+{ Older (pre-V53, MorphOS v3.18) TinyGL's ABI for glViewport() did not respect OpenGL
+  conventions, and expected the viewport coordinates in floats. This was deprecated
+  and no longer present in the public C headers, but the library still respects the
+  old ABI, and will keep doing so. There was a new function added with the right
+  argument types, at offset 1912. See _GLViewport() below. }
+procedure _GLViewportOld(gcl: pointer; x, y: GLfloat; width, height: GLfloat);
 syscall sysvbase TinyGLBase 244;
 
 procedure _GLFrustum(gcl: pointer; left, right, bottom, top, zNear, zFar: GLdouble);
@@ -347,6 +352,11 @@ procedure _GLCopyTexImage2D(gcl: pointer; target: GLenum; level: GLint; internal
 syscall sysvbase TinyGLBase 1402;
 {$ENDIF GL_UNIT}
 
+{$IFDEF GL_UNIT}
+{ See the comment at _GLViewportOld() }
+procedure _GLViewport(gcl: pointer; x, y: GLint; width, height: GLsizei);
+syscall sysvbase TinyGLBase 1912;
+{$ENDIF GL_UNIT}
 
 { ****************************************************************************************************** }
 { ** GL functions                                                                                     ** }
@@ -760,7 +770,12 @@ end;
 
 procedure glViewport(x, y: GLint; width, height: GLsizei); inline;
 begin
-  _GLViewport(tglContext, x, y, width, height);
+  if PLibrary(TinyGLBase)^.lib_Version >= 53 then
+    _GLViewport(tglContext, x, y, width, height)
+  else
+    { we support calling _GLViewportOld() to work with older TinyGL
+    versions. See the comment there. }
+    _GLViewportOld(tglContext, x, y, width, height);
 end;
 {$ENDIF GL_UNIT}