rendering: fix shader loading

This commit is contained in:
Bixilon 2021-02-13 13:39:55 +01:00
parent 448e83e39d
commit 34c0f5aa31
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -8,21 +8,22 @@ import org.lwjgl.opengl.GL11;
import java.io.IOException;
import static org.lwjgl.opengl.ARBShaderObjects.*;
import static org.lwjgl.system.MemoryUtil.NULL;
public class ShaderUtil {
public static int createShader(String shaderPath, int shaderType) throws ShaderLoadingException, IOException {
int shaderId = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
int shaderId = glCreateShaderObjectARB(shaderType);
if (shaderId == NULL) {
throw new ShaderLoadingException();
}
ARBShaderObjects.glShaderSourceARB(shaderId, Util.readAssetResource("/rendering/shader/" + shaderPath));
ARBShaderObjects.glCompileShaderARB(shaderId);
glShaderSourceARB(shaderId, Util.readAssetResource("rendering/shader/" + shaderPath));
glCompileShaderARB(shaderId);
if (ARBShaderObjects.glGetObjectParameteriARB(shaderId, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) {
if (glGetObjectParameteriARB(shaderId, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE) {
throw new ShaderLoadingException(OpenGLUtil.getLogInfo(shaderId));
}