Thread with 16 posts
jump to expanded postyou know, it’s a shame that C is designed by ISO/IEC JTC1/SC22/WG14 and not the OpenGL Architecture Review Board. i’m sure we’d all rather write:
glDisable(GL_MASKING);
glEnableClientState(GL_SOURCE_DATA_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glSourceDataPointer(1, gl::UNSIGNED_BYTE, 1, dst_ptr);
glEnableClientState(GL_DESTINATION_DATA_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDestinationDataPointer(1, gl::UNSIGNED_BYTE, 1, src_ptr);
glCopyBytes(0, num_bytes);
if (glGetError() != 0) {
// fuck
}
rather than
memcpy(dst_ptr, src_ptr, size);
“client state? in 2023?” i hear you cry. ok ok. surely what we want to do then is
glDisable(GL_MASKING);
glEnableSourceDataArray();
glBindBuffer(GL_ARRAY_BUFFER, src_buf);
glSourceDataPointer(1, gl::UNSIGNED_BYTE, 1, (const GLvoid*)(uintptr_t)src_offset);
glEnableDestinationDataArray();
glBindBuffer(GL_ARRAY_BUFFER, dst_buf);
glDestinationDataPointer(1, gl::UNSIGNED_BYTE, 1, (const GLvoid*)(uintptr_t)dst_offset);
glCopyBytes(0, num_bytes);
if (glGetError() != 0) {
// fuck
}
i should really not find more ways to procrastinate from writing very tedious real opengl code, but… i am extremely tempted to write a strings library for c that uses the same api conventions as opengl, as a joke
ah oops, s/gl::/GL_/, I’ve been writing too much Rust
@hikari
int strings[2];
strCreate(2, & strings);
strBindString(STR_DEST_STRING, string1);
strStringImage1D("hello, ");
strBindString(STR_DEST_STRING, string2);
strStringImage1D("world!");
strBindString (STR_DEST_STRING, string1);
strBindString(STR_SRC_STRING, string2);
strStrCat();
strBindString (STR_SRC_STRING, string1);
strBindFileDescriptor(STR_OUTPUT, 1);
strPutStrLn();
strFlush();
@0x2ba22e11 StringImage1D 😍
@0x2ba22e11 legacy compatibility profile where you can do
strBegin();
strChar('h');
strChar('e');
strChar('l');
strChar('l');
strChar('o');
strEnd();
@hikari 😂
@hikari I was really hoping you'd find that name funny ☺️
@0x2ba22e11 needs more format arguments though. gl::UNICODE, gl::UTF8 etc,
@hikari and if you try to just memcpy something into a buffer you find out the hard way that it's actually in the terminal's RAM as extended EBCDIC characters with the rows and columns of the terminal laid out along a Hilbert curve
Plus several extra buffers for "bright", "color" and "blinking" attributes.
@hikari
now do vulkan
@rectus alas i’ve not learned vulkan yet but i think it would probably be slightly less horrible
@hikari i'm learning vulkan right now by implementing it into my application alongside the already existing directx renderers, and it's even more verbose than directx 12
(i haven't learned opengl yet)
@rectus yeah i expect it’s very verbose, but at least it doesn’t have opengl’s goddamn state machine
@hikari it has asynchronous command recording and resource state barriers instead
copying stuff feels like having to do something like this:
VkCommandBufferBeginInfo beginInfo{ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
vkBeginCommandBuffer(commandBuffer, &beginInfo);
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 2, {src_barrier, dst_barrier});
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, bufferLayout, 0, 1, &descriptorSets, 0, nullptr);
vkCopyBuffers(1, &dst_buffer, 1, &src_buffer, offset, size, nullptr);
vkEndCommandBuffer(commandBuffer);
VkSubmitInfo submitInfo{ VK_STRUCTURE_TYPE_SUBMIT_INFO };
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &commandBuffer;
vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE);
vkQueueWaitIdle(queue);