Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

zopengl wrapper API design#674

hazeycode started this conversation inGeneral
Aug 13, 2024· 4 comments· 4 replies
Discussion options

Pasteing discussion from Discord to start the discussion here...

Should the user be expected to use the GL types as defined in bindings.zig, or should be standard Zig & the types defined in the wrapper?

The wrapper "forwards" types defined by the bindings. A wrapper user shouldn't need to access any definitions from bindings.zig directly.

Some enums (for example, the debug output filter) have an element which may be present but would only be provided to one function but not the rest (e.g. GL_DONT_CARE) should these be part of the enum, defined in-line, part of some extended enum, or from time-to-time allowing a null value to define this extra behaviour?

Ideally functions should only take enums sets where all the members are valid for that function. Note that for some functions enum types are defined inline. And there are probably some mistakes present currently. From the opposite angle wrapper.meta.mergeEnums can be used to merge enum sets.

When data is going to and from OpenGL, what type should generally be preferred? A pointer + offset, or a []u8? This is mostly a fluency question. Textures currently use opaque pointers, while buffers use arrays. Consistency would be nice to have.

Slices should be preferred to pointer+len unless that prevents some functionality. For example glBufferData can be passed a size and a nullptr to allocate memory of size but not write to it.

Getter functions such as getProgramiv seem to generally return their result by value, while creation functions return by reference (in particular, the single-value overrides). For fluency sake, would it make more sense to have both return by value?

The current convention is that gen* procs return by reference and create* procs return by value. For get* procs I'm not sure what is best, there is an argument for both.

You must be logged in to vote

Replies: 4 comments 4 replies

Comment options

Ifzopengl is just a wrapper then dont overcomplicate the api, keep it 1:1. Thousands of tutorials use whateverglThisAndThat function with a specific list of parameters according to the glspec. It wouldn't help the uninitiated OpenGL beginner to be confronted with such things. my 2cents

You must be logged in to vote
4 replies
@hazeycode
Comment options

hazeycodeAug 13, 2024
Maintainer Author

zopengl.bindings offers a 1:1 API.zopengl.wrapper is intended to add a little bit of type safety and better auto-complete to prevent silly mistakes. But I agree that we should be conservative and ensure any deviations are +EV for the user.

@deccer
Comment options

OpenGL has too many quirks unfortunately. I would let the consumer of the bindings decide how and if they want to wrap it somehow to make it more tolerable. But let's see what the other frogs have to say.

@hazeycode
Comment options

hazeycodeAug 13, 2024
Maintainer Author

You may be right. Are there any specific quirks you think are going to be particularly problematic?

@basdxz
Comment options

While I wholeheartedly agree and have used the same argument in the past, I believe in the value of fluency that the wrapper layer offers. It's what drew me tozopengl over other alternatives after all.

The goal should be a paper thin wrapper, not a comprehensive abstraction. And I'm certain that some compromises would have to be made to allow leeway for the 'quirks' of the API.

Comment options

Any interest in discussing this further?

You must be logged in to vote
0 replies
Comment options

hazeycode
May 14, 2025
Maintainer Author

Error handling design discussionzig-gamedev/zopengl#15

You must be logged in to vote
0 replies
Comment options

hazeycode
Jun 25, 2025
Maintainer Author

Some breaking API changes happened (it was me, let me know if you disagree with any decisions here):
zig-gamedev/zopengl#16
zig-gamedev/zopengl#18

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
enhancementNew feature or requesthelp wantedExtra attention is needed
3 participants
@hazeycode@basdxz@deccer

[8]ページ先頭

©2009-2025 Movatter.jp