unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] guile-figl - Add wrappers for common texture functions.
@ 2013-06-13  1:14 David Thompson
  2013-07-19 16:38 ` Daniel Hartwig
  0 siblings, 1 reply; 3+ messages in thread
From: David Thompson @ 2013-06-13  1:14 UTC (permalink / raw)
  To: guile-user; +Cc: David Thompson

Filled in some holes regarding OpenGL texture functions. There are 2
left as TODO that I'm not quite sure how to handle nicely.

---
 figl/gl.scm | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/figl/gl.scm b/figl/gl.scm
index edbd7c8..4924be1 100644
--- a/figl/gl.scm
+++ b/figl/gl.scm
@@ -1,17 +1,17 @@
 ;;; figl
 ;;; Copyright (C) 2013 Andy Wingo <wingo@pobox.com>
 ;;; Copyright (C) 2013 Daniel Hartwig <mandyke@gmail.com>
-;;;
+;;;
 ;;; Figl is free software: you can redistribute it and/or modify it
 ;;; under the terms of the GNU Lesser General Public License as
 ;;; published by the Free Software Foundation, either version 3 of the
 ;;; License, or (at your option) any later version.
-;;;
+;;;
 ;;; Figl is distributed in the hope that it will be useful, but WITHOUT
 ;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 ;;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
 ;;; Public License for more details.
-;;;
+;;;
 ;;; You should have received a copy of the GNU Lesser General Public
 ;;; License along with this program.  If not, see
 ;;; <http://www.gnu.org/licenses/>.
@@ -293,7 +293,75 @@

 (re-export (%glShadeModel . set-gl-shade-model))

-\f
+;;;
+;;; 3.8.1 Texture Image Specification
+;;;
+
+(re-export (%glTexImage3D . gl-texture-image-3d)
+           (%glTexImage2D . gl-texture-image-2d)
+           (%glTexImage1D . gl-texture-image-1d))
+
+;;;
+;;; 3.8.2 Alternate Texture Image Specification Commands
+;;;
+
+(re-export (%glCopyTexImage2D . gl-copy-texture-image-2d)
+           (%glCopyTexImage1D . gl-copy-texture-image-1d)
+           (%glCopyTexSubImage3D . gl-copy-texture-sub-image-3d)
+           (%glCopyTexSubImage2D . gl-copy-texture-sub-image-2d)
+           (%glCopyTexSubImage1D . gl-copy-texture-sub-image-1d)
+           (%glTexSubImage3D . gl-texture-sub-image-3d)
+           (%glTexSubImage2D . gl-texture-sub-image-2d)
+           (%glTexSubImage1D . gl-texture-sub-image-1d))
+
+;;;
+;;; 3.8.3 Compressed Texture Images
+;;;
+
+(re-export (%glCompressedTexImage1D . gl-compressed-texture-image-1d)
+           (%glCompressedTexImage2D . gl-compressed-texture-image-2d)
+           (%glCompressedTexImage3D . gl-compressed-texture-image-3d)
+           (%glCompressedTexSubImage1D . gl-compressed-texture-sub-image-1d)
+           (%glCompressedTexSubImage2D . gl-compressed-texture-sub-image-2d)
+           (%glCompressedTexSubImage3D . gl-compressed-texture-sub-image-3d))
+
+;;;
+;;; 3.8.4 Texture Parameters
+;;;
+
+(re-export  (%glTexParameteri . gl-texture-parameter))
+
+;;;
+;;; 3.8.12 Texture Objects
+;;;
+
+;; TODO gl-are-textures-resident? gl-prioritze-textures
+
+(define (gl-generate-textures n)
+  (let ((bv (make-u32vector n 0)))
+    (%glGenTextures n bv)
+    (u32vector->list bv)))
+
+(define (gl-generate-texture)
+  (car (gl-generate-textures 1)))
+
+(define (gl-delete-textures textures)
+  (let ((bv (list->u32vector textures)))
+    (%glDeleteTextures (u32vector-length bv) bv)))
+
+;; emacs: (put 'with-gl-bind-texture 'scheme-indent-function 2)
+(define-syntax-rule (with-gl-bind-texture target id body ...)
+  (begin
+    (%glBindTexture target id)
+    body
+    ...
+    (%glBindTexture target 0)))
+
+(export gl-generate-textures
+        gl-generate-texture
+        gl-delete-textures
+        with-gl-bind-texture)
+
 ;;;
 ;;; 4.1 Per-Fragment Operations
 ;;;
--
1.8.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] guile-figl - Add wrappers for common texture functions.
  2013-06-13  1:14 [PATCH] guile-figl - Add wrappers for common texture functions David Thompson
@ 2013-07-19 16:38 ` Daniel Hartwig
  2013-07-19 22:53   ` David Thompson
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Hartwig @ 2013-07-19 16:38 UTC (permalink / raw)
  To: David Thompson; +Cc: guile-user

On 13 June 2013 09:14, David Thompson <dthompson2@worcester.edu> wrote:
> Filled in some holes regarding OpenGL texture functions. There are 2
> left as TODO that I'm not quite sure how to handle nicely.
>

Hello

Thanks also for this patch, though I am not applying it at the moment.
 I have inserted some comments inline, and also have opened up another
block of time where I can do more work on this soon.

Note that you can (temporarily) define any missing interfaces in your
local project and avoid asking your users to run a patched figl.
Having looked at this patch, it seems you probably want to just access
the low-level bindings in (figl gl low-level) module directly, and
third party libraries are encouraged to do so.

Anyway, thanks again for the efforts and hope to get more high-level
interfaces shortly.

> ---
>  figl/gl.scm | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 72 insertions(+), 4 deletions(-)
>
> diff --git a/figl/gl.scm b/figl/gl.scm
> index edbd7c8..4924be1 100644
> --- a/figl/gl.scm
> +++ b/figl/gl.scm
> @@ -293,7 +293,75 @@
>
>  (re-export (%glShadeModel . set-gl-shade-model))
>
> -
> +;;;
> +;;; 3.8.1 Texture Image Specification
> +;;;
> +
> +(re-export (%glTexImage3D . gl-texture-image-3d)
> +           (%glTexImage2D . gl-texture-image-2d)
> +           (%glTexImage1D . gl-texture-image-1d))
> +

For the high level interface, we really like to have some sanity
checks on the supplied data.  The same applies to most of the other
re-exports.

Third party libraries are encouraged to directly access these
low-level bindings as appropriate, they are in the (figl gl low-level)
module.

> +;;;
> +;;; 3.8.4 Texture Parameters
> +;;;
> +
> +(re-export  (%glTexParameteri . gl-texture-parameter))
> +

What about float parameters, and vectors?

> +;; emacs: (put 'with-gl-bind-texture 'scheme-indent-function 2)
> +(define-syntax-rule (with-gl-bind-texture target id body ...)
> +  (begin
> +    (%glBindTexture target id)
> +    body
> +    ...
> +    (%glBindTexture target 0)))
> +

With this style it should revert to the previous texture bound to
TARGET, which can be queried and may not be ‘0’.

Regards



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] guile-figl - Add wrappers for common texture functions.
  2013-07-19 16:38 ` Daniel Hartwig
@ 2013-07-19 22:53   ` David Thompson
  0 siblings, 0 replies; 3+ messages in thread
From: David Thompson @ 2013-07-19 22:53 UTC (permalink / raw)
  To: Daniel Hartwig; +Cc: guile-user

On 07/19/2013 12:38 PM, Daniel Hartwig wrote:
> On 13 June 2013 09:14, David Thompson <dthompson2@worcester.edu> wrote:
>> Filled in some holes regarding OpenGL texture functions. There are 2
>> left as TODO that I'm not quite sure how to handle nicely.
>>
> Hello
>
> Thanks also for this patch, though I am not applying it at the moment.
>   I have inserted some comments inline, and also have opened up another
> block of time where I can do more work on this soon.
>
> Note that you can (temporarily) define any missing interfaces in your
> local project and avoid asking your users to run a patched figl.
> Having looked at this patch, it seems you probably want to just access
> the low-level bindings in (figl gl low-level) module directly, and
> third party libraries are encouraged to do so.
>
> Anyway, thanks again for the efforts and hope to get more high-level
> interfaces shortly.
>
>> ---
>>   figl/gl.scm | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
>>   1 file changed, 72 insertions(+), 4 deletions(-)
>>
>> diff --git a/figl/gl.scm b/figl/gl.scm
>> index edbd7c8..4924be1 100644
>> --- a/figl/gl.scm
>> +++ b/figl/gl.scm
>> @@ -293,7 +293,75 @@
>>
>>   (re-export (%glShadeModel . set-gl-shade-model))
>>
>> -
>> +;;;
>> +;;; 3.8.1 Texture Image Specification
>> +;;;
>> +
>> +(re-export (%glTexImage3D . gl-texture-image-3d)
>> +           (%glTexImage2D . gl-texture-image-2d)
>> +           (%glTexImage1D . gl-texture-image-1d))
>> +
> For the high level interface, we really like to have some sanity
> checks on the supplied data.  The same applies to most of the other
> re-exports.
>
> Third party libraries are encouraged to directly access these
> low-level bindings as appropriate, they are in the (figl gl low-level)
> module.
Then that is what I'll do for my project, then. Thanks.
>
>> +;;;
>> +;;; 3.8.4 Texture Parameters
>> +;;;
>> +
>> +(re-export  (%glTexParameteri . gl-texture-parameter))
>> +
> What about float parameters, and vectors?'
>
>> +;; emacs: (put 'with-gl-bind-texture 'scheme-indent-function 2)
>> +(define-syntax-rule (with-gl-bind-texture target id body ...)
>> +  (begin
>> +    (%glBindTexture target id)
>> +    body
>> +    ...
>> +    (%glBindTexture target 0)))
>> +
> With this style it should revert to the previous texture bound to
> TARGET, which can be queried and may not be ‘0’.

Good point.
>
> Regards

Thanks for the helpful feedback. Now I know a bit more about the 
guidelines for the high level interface. I'll just use (figl gl 
low-level) for now.

- Dave



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-19 22:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13  1:14 [PATCH] guile-figl - Add wrappers for common texture functions David Thompson
2013-07-19 16:38 ` Daniel Hartwig
2013-07-19 22:53   ` David Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).