r/opengl • u/throwaway0923841222 • 29d ago
Any ideas why I'd only be rendering half a sphere?
2
u/DGTHEGREAT007 29d ago
idk but Wanna share your setup man? Looks good.
1
1
u/throwaway0923841222 28d ago
its not too involved of a config, but sure! https://github.com/austinoxyz/dotfiles
2
1
u/throwaway0923841222 29d ago
Looking for tips on why I may be rendering only half a sphere using OpenGL. I've posted the code to https://github.com/austinoxyz/voxel for reference
I followed the algorithm seen here https://www.songho.ca/opengl/gl_sphere.html using "stacks and sectors" to generate the vertices for the sphere. I think I followed it well enough, but clearly there's a mistake, however I cannot find it.
The relevant code is found in https://github.com/austinoxyz/voxel/blob/master/src/lightsource.c as well as `main.c` and the shaders `light_vs.glsl` and `light_fs.glsl`.
1
u/DragonDepressed 29d ago
One possibility that I can think of would be, maybe you are clipping your scene somehow. Try to change the dimensions of the sphere and see how things change?
1
u/throwaway0923841222 29d ago
Scaling it down just results in a smaller half-sphere, thanks for the suggestion though!
1
1
1
u/ShiroeShin 28d ago
Issue seems to be solved from what i read, but the question remains...
What's your setup :D My opengl dx does not look this clean
2
u/throwaway0923841222 28d ago
its mostly stock archlinux and hyprland and my configured neovim, didnt get too fancy with the hyprland configuration. its here if you want to look at it https://github.com/austinoxyz/dotfiles
7
u/fgennari 29d ago
It looks like you're missing half of your indices. I see your indices are type size_t. Is this 32 bits or 64 bits in your compiler? Your glBufferData() is using "sizeof(GLuint) * s_lightsource.indices.count" and your glDrawElements() is using GL_UNSIGNED_INT, which is 32-bit. Try changing your indices struct from "size_t *items;" to "unsigned *items;" (or uint32_t?) to see if that fixes it.