Inertia's picture

Enum: Vertex Buffer Object (Version15) [done!]

VBO
http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt

EnableCaps using this Extension are Vertex-Array ones, e.g. EnableCap.NormalArray

The new Enums (see below) affect these functions:

old: GL.BindBuffer( Version15 target, XXXXX );
new: GL.BindBuffer( BufferTarget target, XXXXX );
*
old: GL.BufferData( Version15 target, XXXXX, XXXXX, Version15 usage );
new: GL.BufferData( BufferTarget target, XXXXX, XXXXX, BufferUsageHint usage );
*
old: GL.BufferSubData( Version15 target, XXXXX, XXXXX, XXXXX );
new: GL.BufferSubData( BufferTarget target, XXXXX, XXXXX, XXXXX );
*
old: GL.GetBufferSubData( Version15 target, XXXXX, XXXXX, XXXXX );
new: GL.GetBufferSubData( BufferTarget target, XXXXX, XXXXX, XXXXX );
*
old: GL.GetBufferParameter( Version15 target, Version15 param, XXXXX );
new: GL.GetBufferParameter( BufferTarget target, BufferParameterName param, XXXXX );
*
old: GL.GetBufferPointer( Version15 target, Version15 param, XXXXX );
new: GL.GetBufferPointer( BufferTarget target, BufferPointer param, XXXXX );
*
old: GL.MapBuffer( Version15 target, Version15 access );
new: GL.MapBuffer( BufferTarget target, BufferAccess access );
*
old: GL.UnmapBuffer( Version15 target );
new: GL.UnmapBuffer( BufferTarget target );

The XXXXX marks unmodified parameters.

        public enum BufferTarget: int // shared by all VBO functions
        {
            ArrayBuffer = ((int)0x8892),
            ElementArrayBuffer = ( (int) 0x8893 ),
        }
 
            public enum BufferUsageHint: int // used only by GL.BufferData
        {
            StreamDraw = ((int)0x88e0),
            StreamRead = ( (int) 0x88e1 ),
            StreamCopy = ( (int) 0x88e2 ),
            StaticDraw = ( (int) 0x88e4 ),
            StaticCopy = ( (int) 0x88e6 ),
            StaticRead = ( (int) 0x88e5 ),
            DynamicRead = ( (int) 0x88e9 ),
            DynamicDraw = ( (int) 0x88e8 ),
            DynamicCopy = ( (int) 0x88ea ),
    }
        public enum BufferAccess:int // only used by GL.MapBuffer
        {
            ReadWrite = ( (int) 0x88ba ),
            ReadOnly = ( (int) 0x88b8 ),
            WriteOnly = ( (int) 0x88b9 ),
        }
        public enum BufferParameterName : int //  only used by GL.GetBufferParameter
        {
            BufferAccess = ( (int) 0x88bb ),
            BufferUsage = ( (int) 0x8765 ),
            BufferSize = ( (int) 0x8764 ),
            BufferMapped = ( (int) 0x88bc ),
        }
        public enum BufferPointer : int // only used by GL.GetBufferPointer
        {
            BufferMapPointer = ( (int) 0x88bd ), 
        }
 
     ------->extends enum GetPName:int
        { // all these buffer bindings must be added to GL.GetInteger's  enum GetPName
 
            ArrayBufferBinding = ( (int) 0x8894 ),
            NormalArrayBufferBinding = ( (int) 0x8897 ),
            TextureCoordArrayBufferBinding = ( (int) 0x889a ),
            SecondaryColorArrayBufferBinding = ( (int) 0x889c ),
            FogCoordArrayBufferBinding = ( (int) Version15.FogCoordinateArrayBufferBinding ), // identical
            FogCoordinateArrayBufferBinding = ( (int) 0x889d ), // identical, remove 1?
            ElementArrayBufferBinding = ( (int) 0x8895 ),
            WeightArrayBufferBinding = ( (int) 0x889e ),
            IndexArrayBufferBinding = ( (int) 0x8899 ),
            VertexAttribArrayBufferBinding = ( (int) 0x889f ),
            EdgeFlagArrayBufferBinding = ( (int) 0x889b ),
            VertexArrayBufferBinding = ( (int) 0x8896 ),
            ColorArrayBufferBinding = ( (int) 0x8898 ),
        }

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Inertia's picture

Formatting is broken, but that shouldn't be an issue.

I think it'll be better to do this Extension by Extension rather than by VersionXX enums. Like this it is easier to verify correctness, and avoids problems on enums referencing into other enums.

Refactor as you see fit, I just derived the enum names from the Extension specs.

Is this formatting acceptable? Or would some other formating help you making the changes?

What's currently left of the Version15 enum is:

public enum Version15
        {
            FogCoordArrayType = ( (int) Version14.FogCoordinateArrayType ),
            FogCoordSrc = ( (int) Version14.FogCoordinateSource ),
            CurrentFogCoord = ( (int) Version14.CurrentFogCoordinate ),
            FogCoord = ( (int) Version14.FogCoordinate ),
            FogCoordArrayStride = ( (int) Version14.FogCoordinateArrayStride ),
            FogCoordArrayPointer = ( (int) Version14.FogCoordinateArrayPointer ),
            FogCoordArray = ( (int) Version14.FogCoordinateArray ),
 
            Src0Rgb = ((int)Version13.Source0Rgb),
            Src2Rgb = ( (int) Version13.Source2Rgb ),
            Src1Rgb = ( (int) Version13.Source1Rgb ),
            Src0Alpha = ( (int) Version13.Source0Alpha ),
            Src1Alpha = ( (int) Version13.Source1Alpha ),
            Src2Alpha = ( (int) Version13.Source2Alpha ),
        }

I'll put that into appropriate enums too, just starting with the major bit of Version15 first.

the Fiddler.'s picture

I don't know what to say man, this stuff is... this stuff is great, thanks! Never mind the formatting, by this time tomorrow we'll have this part of the specs fixed :)

Regarding Version15.FogCoordinateArrayBufferBinding, this name was marked as invalid by the ARB (it should have been "Coord", not "Coordinate"), so I'll just remove it.

Inertia's picture

this time tomorrow we'll have this part of the specs fixed :)
The weekend is probably more realistic ;) I've taken a quick sort through Version20/21 (Visual Studio allows to cut&paste using only the mouse which is extremely fast), and I think the Shaders bit will be the most complicated to unwire.
I'll fix all non-shaders related enums first i.e. the Version1x enums.

P.S: You will have to fix the build errors from enums trying to pull their constant value from Version15 enum. Maybe generate a new All-enum which explicitly defines all constants in it, rather than trying to manually fix the errors.

P.P.S: Version15 is now obsolete, the Fog* and Src* constants don't really belong to it. Yey!

P.P.P.S: Feel free to edit the subject of the posts into something that helps you keep track of what you included (e.g. "[done] Vertex Buffer Object (Version15)" or something like this). Their order will change if they get a reply/edit.

the Fiddler's picture

[build errors]
I'm editing the source specs directly and the generator will adapt automatically. The generator has three rules for enum parameters:

  1. if the enum exists, use it
  2. if not, but the function has a version defined (e.g. Version15), use that
  3. if all else fails, fall back onto the All enum

In theory, a build error should only occur if we forgot to update a function relying on (e.g.) Version15 to use a more specific enum. We'll see what happens, soon :)

Inertia's picture

Sorry didn't see this post earlier.

Editing the specs is a good idea :) I've used the whitepapers to verify the enum corrections I posted, and only fall back to the .spec if finding the appropriate paper failed.

Btw. I've not removed/added anything to the pre-defined VersionXX enums, I've just taken them as they were. I'll take a look at the Version20/1 enums later, but don't expect them to be complete today. Need food. Need water. Need to see something that is not black&white ;)

I hope all this will compile well (it doesn't for me atm, because enums are fetching values from removed ones), cannot wait to test how programming with the new enums is like.

the Fiddler's picture

Hey, there's no need to complete everything in one go :) This stuff alone warrants a new release, there's no problem leaving Version20/21 for later.

the Fiddler's picture

This is one of the most important updates for OpenTK. Just this one uncovered two crash-errors in the VboTextPrinter implementation. Thumbs up!

Inertia's picture

"uncovered two crash-errors"
Yeah, using the old VersionXX enums was really errorprone. Working on removing them all, so we can forget about them :-)