L Corbijn | 16 Jan 2012 12:19
Picon
Gravatar

OpenGLRaw naming convention

Hello HOpenGL,

While working on my OpenGLRaw-generator which is getting quite good
(current OpenGL compiles with minor changes) I've come to wonder/worry
about the current naming convention of Raw.

The current naming scheme of OpenGLRaw can best be described as, try
to remove the vendor names (NV, ARB, etc. suffixes) unless it will
result in a conflict. To give two examples, MultiTexCoord2dARB ->
MultiTexCoord2d, as there is none defined otherwise, while
glPrimitiveRestartIndexNV keeps it's name as glPrimitiveRestartIndex
is a different function.

When generating code I've come across a few nasty disadvantages with
no obvious solution in this scheme.
1. What to do when two or more vendors have the same enum/function
which should be promoted to the one without vendor name.
2. The mixing of functions with and without vendor name, e.g.
glPrimitiveRestart, glPrimitiveRestartIndexNV from NVidia's
PrimitiveRestart extension.
3. Breaking changes, what if a new extension or even a new OpenGL
version adds a different enum/function with the same name (without
vender part), as the striped name collides the extension must be
re-added leading to some code breaking (maybe even silently!).
The only advantage I see is that two enums/functions who differ in
name also differ in value/implementation.

Therefore I would like to know what people think about the current
naming convention, and whether it would be a major issue to change it
(probably to keeping the vendor names everywhere).
(Continue reading)

Picon
Favicon

Invitation to connect on LinkedIn

LinkedIn

Stan Serebryakov requested to add you as a connection on LinkedIn:

Christopher,

I'd like to add you to my professional network on LinkedIn.

- Stan

 
View invitation from Stan Serebryakov

 

WHY MIGHT CONNECTING WITH STAN SEREBRYAKOV BE A GOOD IDEA?

Stan Serebryakov's connections could be useful to you

After accepting Stan Serebryakov's invitation, check Stan Serebryakov's connections to see who else you may know and who you might want an introduction to. Building these connections can create opportunities in the future.

 

© 2011, LinkedIn Corporation

_______________________________________________
HOpenGL mailing list
HOpenGL <at> haskell.org
http://www.haskell.org/mailman/listinfo/hopengl
Jason Dagit | 16 Jan 2012 20:55
Picon
Gravatar

Re: OpenGLRaw naming convention

On Mon, Jan 16, 2012 at 3:19 AM, L Corbijn <aspergesoepje <at> gmail.com> wrote:
> Hello HOpenGL,
>
> While working on my OpenGLRaw-generator which is getting quite good
> (current OpenGL compiles with minor changes) I've come to wonder/worry
> about the current naming convention of Raw.
>
> The current naming scheme of OpenGLRaw can best be described as, try
> to remove the vendor names (NV, ARB, etc. suffixes) unless it will
> result in a conflict. To give two examples, MultiTexCoord2dARB ->
> MultiTexCoord2d, as there is none defined otherwise, while
> glPrimitiveRestartIndexNV keeps it's name as glPrimitiveRestartIndex
> is a different function.
>
> When generating code I've come across a few nasty disadvantages with
> no obvious solution in this scheme.
> 1. What to do when two or more vendors have the same enum/function
> which should be promoted to the one without vendor name.
> 2. The mixing of functions with and without vendor name, e.g.
> glPrimitiveRestart, glPrimitiveRestartIndexNV from NVidia's
> PrimitiveRestart extension.
> 3. Breaking changes, what if a new extension or even a new OpenGL
> version adds a different enum/function with the same name (without
> vender part), as the striped name collides the extension must be
> re-added leading to some code breaking (maybe even silently!).
> The only advantage I see is that two enums/functions who differ in
> name also differ in value/implementation.
>
> Therefore I would like to know what people think about the current
> naming convention, and whether it would be a major issue to change it
> (probably to keeping the vendor names everywhere).

Two ideas:
  * What about having the "RAW" api keep the names verbatim and other
layers on top rename things?  Basically, defer this decision to a
different point.
  * Collect all the Foo versions in a Foo module and then remove the
Foo from the names inside the module.

Does that make sense?  Are either of these possible with your bindings
generator?

I don't mind if the names have NV or ARB in them, but I may represent
a minority opinion.

Jason
L Corbijn | 16 Jan 2012 22:16
Picon
Gravatar

Re: OpenGLRaw naming convention

On Mon, Jan 16, 2012 at 8:55 PM, Jason Dagit <dagitj <at> gmail.com> wrote:
> On Mon, Jan 16, 2012 at 3:19 AM, L Corbijn <aspergesoepje <at> gmail.com> wrote:
>> Hello HOpenGL,
>>
>> While working on my OpenGLRaw-generator which is getting quite good
>> (current OpenGL compiles with minor changes) I've come to wonder/worry
>> about the current naming convention of Raw.
>>
>> The current naming scheme of OpenGLRaw can best be described as, try
>> to remove the vendor names (NV, ARB, etc. suffixes) unless it will
>> result in a conflict. To give two examples, MultiTexCoord2dARB ->
>> MultiTexCoord2d, as there is none defined otherwise, while
>> glPrimitiveRestartIndexNV keeps it's name as glPrimitiveRestartIndex
>> is a different function.
>>
>> When generating code I've come across a few nasty disadvantages with
>> no obvious solution in this scheme.
>> 1. What to do when two or more vendors have the same enum/function
>> which should be promoted to the one without vendor name.
>> 2. The mixing of functions with and without vendor name, e.g.
>> glPrimitiveRestart, glPrimitiveRestartIndexNV from NVidia's
>> PrimitiveRestart extension.
>> 3. Breaking changes, what if a new extension or even a new OpenGL
>> version adds a different enum/function with the same name (without
>> vender part), as the striped name collides the extension must be
>> re-added leading to some code breaking (maybe even silently!).
>> The only advantage I see is that two enums/functions who differ in
>> name also differ in value/implementation.
>>
>> Therefore I would like to know what people think about the current
>> naming convention, and whether it would be a major issue to change it
>> (probably to keeping the vendor names everywhere).
>
> Two ideas:
>  * What about having the "RAW" api keep the names verbatim and other
> layers on top rename things?  Basically, defer this decision to a
> different point.

So not renaming anything, that's simple, see the noNameStrip branch.

>  * Collect all the Foo versions in a Foo module and then remove the
> Foo from the names inside the module.

This is also not so hard and is implemented in the allNameStrip
branch. Though this creates conflicts in the 'vendor' module (at least
I got one from the ARB module using e.g. TEXTURE_BLUE_TYPE with and
without suffix), which of course can be fixed by some extra code. This
extra code is already in the develop branch (the renameValue stuff)
but is also very resource hungry at the moment.

> Does that make sense?  Are either of these possible with your bindings
> generator?

Both options make sense and that makes the decision a harder one.
Personally I prefer the first because you get what you asked for (and
you can ask what you need not for something else). As for the
generator, I wouldn't program if I didn't like to tackle problems...

Lars

P.S. Does somebody have a good suggestion on a library for
command-line-options parsing?
Jason Dagit | 16 Jan 2012 22:53
Picon
Gravatar

Re: OpenGLRaw naming convention

On Mon, Jan 16, 2012 at 1:16 PM, L Corbijn <aspergesoepje <at> gmail.com> wrote:
> On Mon, Jan 16, 2012 at 8:55 PM, Jason Dagit <dagitj <at> gmail.com> wrote:
>> On Mon, Jan 16, 2012 at 3:19 AM, L Corbijn <aspergesoepje <at> gmail.com> wrote:
>>> Hello HOpenGL,
>>>
>>> While working on my OpenGLRaw-generator which is getting quite good
>>> (current OpenGL compiles with minor changes) I've come to wonder/worry
>>> about the current naming convention of Raw.
>>>
>>> The current naming scheme of OpenGLRaw can best be described as, try
>>> to remove the vendor names (NV, ARB, etc. suffixes) unless it will
>>> result in a conflict. To give two examples, MultiTexCoord2dARB ->
>>> MultiTexCoord2d, as there is none defined otherwise, while
>>> glPrimitiveRestartIndexNV keeps it's name as glPrimitiveRestartIndex
>>> is a different function.
>>>
>>> When generating code I've come across a few nasty disadvantages with
>>> no obvious solution in this scheme.
>>> 1. What to do when two or more vendors have the same enum/function
>>> which should be promoted to the one without vendor name.
>>> 2. The mixing of functions with and without vendor name, e.g.
>>> glPrimitiveRestart, glPrimitiveRestartIndexNV from NVidia's
>>> PrimitiveRestart extension.
>>> 3. Breaking changes, what if a new extension or even a new OpenGL
>>> version adds a different enum/function with the same name (without
>>> vender part), as the striped name collides the extension must be
>>> re-added leading to some code breaking (maybe even silently!).
>>> The only advantage I see is that two enums/functions who differ in
>>> name also differ in value/implementation.
>>>
>>> Therefore I would like to know what people think about the current
>>> naming convention, and whether it would be a major issue to change it
>>> (probably to keeping the vendor names everywhere).
>>
>> Two ideas:
>>  * What about having the "RAW" api keep the names verbatim and other
>> layers on top rename things?  Basically, defer this decision to a
>> different point.
>
> So not renaming anything, that's simple, see the noNameStrip branch.
>
>>  * Collect all the Foo versions in a Foo module and then remove the
>> Foo from the names inside the module.
>
> This is also not so hard and is implemented in the allNameStrip
> branch. Though this creates conflicts in the 'vendor' module (at least
> I got one from the ARB module using e.g. TEXTURE_BLUE_TYPE with and
> without suffix), which of course can be fixed by some extra code. This
> extra code is already in the develop branch (the renameValue stuff)
> but is also very resource hungry at the moment.
>
>> Does that make sense?  Are either of these possible with your bindings
>> generator?
>
> Both options make sense and that makes the decision a harder one.
> Personally I prefer the first because you get what you asked for (and
> you can ask what you need not for something else). As for the
> generator, I wouldn't program if I didn't like to tackle problems...

Great :)

>
> Lars
>
> P.S. Does somebody have a good suggestion on a library for
> command-line-options parsing?

I've tried several and while cmdargs gives you an API where you don't
have to repeat yourself, it uses unsafePerformIO under the hood and as
such I tend to only use it for toy programs.

When the code is going into production getopt is the one I prefer (and
same goes for most of the folks at work).

http://www.haskell.org/haskellwiki/GetOpt

I hope that helps,
Jason
Achim Krause | 20 Jan 2012 12:58
Picon

Conversion of GLsizei to GLfloat

Hello everyone,
I'm making my first experiences with OpenGL at the moment. It's really
nice to use, but I got one issue which really freaks me out:
Let's say I want to create a square-grid across the whole screen as
background of a very basic 2D game. The application is meant to run in
full screen mode. Since I want it to work on different resolutions and
screen formats I introduced an IORef relSize (of type (GLfloat,GLfloat))
which is meant to store the size of the squares relative to the current
window size, and tried to set a reshape callback in the form of
reshape relS s <at> (Size w h) = do
   viewport $= (Position 0 0, s)
   relS $= (size / w, size / h)
where size is just a name for the (at another place) defined absolute
size for the squares. The Problem is that i see absolutely no way to
convert w and h (which are of type GLsizei) in order to yield a value of
type GLfloat. Is there any way to extract a Haskell Integer value from
values of type GLsizei and convert a Haskell Float value to a GLfloat?
Or is there a more direct way to do what I'm trying to achieve?
The only solution i've come up with so far is using read.show as
converter, which cannot really be the intended way of doing this.
Thank you very much!
Sincerely, Achim Krause
Jason Dagit | 20 Jan 2012 15:32
Picon
Gravatar

Re: Conversion of GLsizei to GLfloat

On Fri, Jan 20, 2012 at 3:58 AM, Achim Krause <info <at> achim-krause.de> wrote:
> Hello everyone,
> I'm making my first experiences with OpenGL at the moment. It's really
> nice to use, but I got one issue which really freaks me out:
> Let's say I want to create a square-grid across the whole screen as
> background of a very basic 2D game. The application is meant to run in
> full screen mode. Since I want it to work on different resolutions and
> screen formats I introduced an IORef relSize (of type (GLfloat,GLfloat))
> which is meant to store the size of the squares relative to the current
> window size, and tried to set a reshape callback in the form of
> reshape relS s <at> (Size w h) = do
>  viewport $= (Position 0 0, s)
>  relS $= (size / w, size / h)
> where size is just a name for the (at another place) defined absolute
> size for the squares. The Problem is that i see absolutely no way to
> convert w and h (which are of type GLsizei) in order to yield a value of
> type GLfloat. Is there any way to extract a Haskell Integer value from
> values of type GLsizei and convert a Haskell Float value to a GLfloat?
> Or is there a more direct way to do what I'm trying to achieve?

Conversion between numeric types is something that trips up everyone
in Haskell when they first encounter it, so don't feel bad.

Almost anytime you are going from some type of integer to something
else you use fromIntegral.  As an example:

GHCi, version 7.2.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> import Graphics.Rendering.OpenGL
Prelude Graphics.Rendering.OpenGL> let a = 1 :: GLsizei
Loading package OpenGLRaw-1.1.0.1 ... linking ... done.
Prelude Graphics.Rendering.OpenGL> let b = 2 :: GLfloat
Prelude Graphics.Rendering.OpenGL> a + b

<interactive>:0:5:
    Couldn't match expected type `GLsizei' with actual type `GLfloat'
    In the second argument of `(+)', namely `b'
    In the expression: a + b
    In an equation for `it': it = a + b
Prelude Graphics.Rendering.OpenGL> fromIntegral a + b
3.0

I hope that helps,
Jason
L Corbijn | 24 Jan 2012 18:19
Picon
Gravatar

Raw generator

Hi,

The raw generator is quite complete. As far as I can see it does work,
and has the option for a compatibility layer for the old core and
produces the correct code (although that's hard to verify with 300+
modules ;) ). In addition I don't see many points of improvement to
the output  nor the internal structure. Therefore I would like to know
if the generated code and program is correct/good/according to
specification i.e. should it be changed? Because (as said) as far as I
can see it is all working.

For those of you who like to build it, the instructions are at the
end. If people would prefer an archive above the hassle of generating
it themselves please let me know.

Lars

* Build instructions *

The non hackage dependencies are:
opengl-api [1] includes some modifications on noteeds (thank you)
package for parsing the spec files.
CodeGenerating [2] a package with utility functions on top of haskell-src-exts

The generator can be found at [3] when compiled run it from the
directory with the source files (build root).
When running the generator the following options are probably useful:
--no-vendorf=novendor (removes the extensions from vendors listed in
the novendor file, to reduce the output a bit)
-o output (output to the `output` subdirectory)
-c (generate compatibility with the current OpenGLRaw)

[1] https://github.com/Laar/opengl-api
[2] https://github.com/Laar/CodeGenerating
[3] https://github.com/Laar/OpenGLRawgen
Vo Minh Thu | 24 Jan 2012 20:21
Picon
Gravatar

Re: Raw generator

2012/1/24 L Corbijn <aspergesoepje <at> gmail.com>:
> Hi,
>
> The raw generator is quite complete. As far as I can see it does work,
> and has the option for a compatibility layer for the old core and
> produces the correct code (although that's hard to verify with 300+
> modules ;) ). In addition I don't see many points of improvement to
> the output  nor the internal structure. Therefore I would like to know
> if the generated code and program is correct/good/according to
> specification i.e. should it be changed? Because (as said) as far as I
> can see it is all working.
>
> For those of you who like to build it, the instructions are at the
> end. If people would prefer an archive above the hassle of generating
> it themselves please let me know.
>
> Lars
>
> * Build instructions *
>
> The non hackage dependencies are:
> opengl-api [1] includes some modifications on noteeds (thank you)
> package for parsing the spec files.
> CodeGenerating [2] a package with utility functions on top of haskell-src-exts
>
> The generator can be found at [3] when compiled run it from the
> directory with the source files (build root).
> When running the generator the following options are probably useful:
> --no-vendorf=novendor (removes the extensions from vendors listed in
> the novendor file, to reduce the output a bit)
> -o output (output to the `output` subdirectory)
> -c (generate compatibility with the current OpenGLRaw)
>
> [1] https://github.com/Laar/opengl-api
> [2] https://github.com/Laar/CodeGenerating
> [3] https://github.com/Laar/OpenGLRawgen

Hi Lars,

I haven't look at the produced code but I will look into releasing
opengl-api to hackage, so you can do the same with your tools if you
want.

Thanks,
Thu

Gmane