Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //drawRectangleRepeated(int x, int y, float u, float v, float uMax, float vMax, int width, int height, int tileWidth, int tileHeight, int zLevel)
- loadShaders();
- glUseProgram(program);
- glUniform1i(texLocation, 0);
- glUniform2f(iconOffsetLocation, u, v);
- glUniform2f(iconSizeLocation, uMax - u, vMax - v);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- drawRectangleStretched(x, y, 0, 0, width, height, 2F, 2F, zLevel);
- glUseProgram(0);
- private static int fragShader, texLocation, iconOffsetLocation, iconSizeLocation = 0;
- private static int program = 0;
- public static void loadShaders()
- {
- if (program == 0)
- try
- {
- program = glCreateProgram();
- fragShader = createShader(new ResourceLocation("malisiscore", "shaders/repeat_frag.glsl"), GL_FRAGMENT_SHADER);
- glAttachShader(program, fragShader);
- glLinkProgram(program);
- glValidateProgram(program);
- texLocation = glGetUniformLocation(program, "tex");
- iconOffsetLocation = glGetUniformLocation(program, "iconOffset");
- iconSizeLocation = glGetUniformLocation(program, "iconSize");
- IntBuffer iVal = BufferUtils.createIntBuffer(1);
- glGetProgram(program, GL_INFO_LOG_LENGTH, iVal);
- int length = iVal.get();
- if (length > 1)
- {
- System.err.println("true");
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- private static int createShader(ResourceLocation file, int shaderType) throws Exception
- {
- int shader = 0;
- try
- {
- shader = glCreateShader(shaderType);
- if (shader == 0)
- return 0;
- glShaderSource(shader, readFileAsString(getMC().getResourceManager().getResource(file).getInputStream()));
- glCompileShader(shader);
- return shader;
- }
- catch (Exception exc)
- {
- glDeleteShader(shader);
- throw exc;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement