Skip to content

Commit 0ab263e

Browse files
authored
Added OpenGL 1.5 query functions to wrapper (#24)
1 parent 4213727 commit 0ab263e

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

src/wrapper.zig

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub fn Wrap(comptime bindings: anytype) type {
4141
pub const Shader = enum(Uint) { invalid = 0, _ };
4242
pub const Program = enum(Uint) { invalid = 0, _ };
4343
pub const Texture = enum(Uint) { invalid = 0, _ };
44+
pub const Query = enum(Uint) { invalid = 0, _ };
4445
pub const Buffer = enum(Uint) { invalid = 0, _ };
4546
pub const VertexArrayObject = enum(Uint) { invalid = 0, _ };
4647

@@ -1161,6 +1162,51 @@ pub fn Wrap(comptime bindings: anytype) type {
11611162
pack_compressed_block_size = PACK_COMPRESSED_BLOCK_SIZE,
11621163
};
11631164

1165+
pub const QueryTarget = enum(Enum) {
1166+
//--------------------------------------------------------------------------------------
1167+
// OpenGL 1.5 (Core Profile)
1168+
//--------------------------------------------------------------------------------------
1169+
samples_passed = SAMPLES_PASSED,
1170+
//--------------------------------------------------------------------------------------
1171+
// OpenGL 3.0 (Core Profile)
1172+
//--------------------------------------------------------------------------------------
1173+
primitives_generated = PRIMITIVES_GENERATED,
1174+
transform_feedback_primitives_written = TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
1175+
//--------------------------------------------------------------------------------------
1176+
// OpenGL 3.3 (Core Profile)
1177+
//--------------------------------------------------------------------------------------
1178+
any_samples_passed = ANY_SAMPLES_PASSED,
1179+
time_elapsed = TIME_ELAPSED,
1180+
//--------------------------------------------------------------------------------------
1181+
// OpenGL 4.3 (Core Profile)
1182+
//--------------------------------------------------------------------------------------
1183+
any_samples_passed_conservative = ANY_SAMPLES_PASSED_CONSERVATIVE,
1184+
};
1185+
1186+
pub const QueryParameter = enum(Enum) {
1187+
//--------------------------------------------------------------------------------------
1188+
// OpenGL 1.5 (Core Profile)
1189+
//--------------------------------------------------------------------------------------
1190+
current_query = CURRENT_QUERY,
1191+
query_counter_bits = QUERY_COUNTER_BITS,
1192+
};
1193+
1194+
pub const QueryObjectParameter = enum(Enum) {
1195+
//--------------------------------------------------------------------------------------
1196+
// OpenGL 1.5 (Core Profile)
1197+
//--------------------------------------------------------------------------------------
1198+
query_result = QUERY_RESULT,
1199+
query_result_available = QUERY_RESULT_AVAILABLE,
1200+
//--------------------------------------------------------------------------------------
1201+
// OpenGL 4.4 (Core Profile)
1202+
//--------------------------------------------------------------------------------------
1203+
query_result_no_wait = QUERY_RESULT_NO_WAIT,
1204+
//--------------------------------------------------------------------------------------
1205+
// OpenGL 4.5 (Core Profile)
1206+
//--------------------------------------------------------------------------------------
1207+
query_target = QUERY_TARGET,
1208+
};
1209+
11641210
pub const BufferTarget = enum(Enum) {
11651211
//--------------------------------------------------------------------------------------
11661212
// OpenGL 1.5 (Core Profile)
@@ -2488,13 +2534,63 @@ pub fn Wrap(comptime bindings: anytype) type {
24882534
pub const SRC1_ALPHA = bindings.SRC1_ALPHA;
24892535

24902536
// pub var genQueries: *const fn (n: Sizei, ids: [*c]Uint) callconv(.c) void = undefined;
2537+
pub fn genQuery(ptr: *Query) void {
2538+
bindings.genQueries(1, @as([*c]Uint, @ptrCast(ptr)));
2539+
}
2540+
pub fn genQueries(queries: []Query) void {
2541+
bindings.genQueries(@intCast(queries.len), @as([*c]Uint, @ptrCast(queries.ptr)));
2542+
}
2543+
24912544
// pub var deleteQueries: *const fn (n: Sizei, ids: [*c]const Uint) callconv(.c) void = undefined;
2545+
pub fn deleteQuery(ptr: *const Query) void {
2546+
bindings.deleteQueries(1, @as([*c]const Uint, @ptrCast(ptr)));
2547+
}
2548+
pub fn deleteQueries(queries: []const Query) void {
2549+
bindings.deleteQueries(@intCast(queries.len), @as([*c]const Uint, @ptrCast(queries.ptr)));
2550+
}
2551+
24922552
// pub var isQuery: *const fn (id: Uint) callconv(.c) Boolean = undefined;
2553+
pub fn isQuery(query: Query) bool {
2554+
return bindings.isQuery(@intFromEnum(query)) == TRUE;
2555+
}
2556+
24932557
// pub var beginQuery: *const fn (target: Enum, id: Uint) callconv(.c) void = undefined;
2558+
pub fn beginQuery(target: QueryTarget, query: Query) void {
2559+
bindings.beginQuery(@intFromEnum(target), @intFromEnum(query));
2560+
}
2561+
24942562
// pub var endQuery: *const fn (target: Enum) callconv(.c) void = undefined;
2563+
pub fn endQuery(target: QueryTarget) void {
2564+
bindings.endQuery(@intFromEnum(target));
2565+
}
2566+
24952567
// pub var getQueryiv: *const fn (target: Enum, pname: Enum, params: [*c]Int) callconv(.c) void = undefined;
2568+
pub fn getQueryiv(
2569+
target: meta.mergeEnums(.{
2570+
QueryTarget,
2571+
enum(Enum) {
2572+
timestamp = TIMESTAMP,
2573+
},
2574+
}),
2575+
pname: QueryParameter,
2576+
params: []i32,
2577+
) void {
2578+
bindings.getQueryiv(
2579+
@intFromEnum(target),
2580+
@intFromEnum(pname),
2581+
@as([*c]Int, @ptrCast(params.ptr)),
2582+
);
2583+
}
2584+
24962585
// pub var getQueryObjectiv: *const fn (id: Uint, pname: Enum, params: [*c]Int) callconv(.c) void = undefined;
2586+
pub fn getQueryObjectiv(query: Query, pname: QueryObjectParameter, params: []i32) void {
2587+
bindings.getQueryObjectiv(@intFromEnum(query), @intFromEnum(pname), @as([*c]Int, @ptrCast(params.ptr)));
2588+
}
2589+
24972590
// pub var getQueryObjectuiv: *const fn (id: Uint, pname: Enum, params: [*c]Uint) callconv(.c) void = undefined;
2591+
pub fn getQueryObjectuiv(query: Query, pname: QueryObjectParameter, params: []u32) void {
2592+
bindings.getQueryObjectuiv(@intFromEnum(query), @intFromEnum(pname), @as([*c]Uint, @ptrCast(params.ptr)));
2593+
}
24982594

24992595
// pub var bindBuffer: *const fn (target: Enum, buffer: Uint) callconv(.c) void = undefined;
25002596
pub fn bindBuffer(target: BufferTarget, buffer: Buffer) void {

0 commit comments

Comments
 (0)