Skip to content
TheChatArchiveThe Chat Archive
o3-mini· OpenAIHugging Face LMArena Human Preference 140K

fun preRender() { GlStateManager.pixelStore(GLUNPACKROWLENGTH, 0)…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Geminigemini-2.5-flash-preview-04-17’s answer.
  1. User

    fun preRender() { GlStateManager._pixelStore(GL_UNPACK_ROW_LENGTH, 0) GlStateManager._pixelStore(GL_UNPACK_SKIP_PIXELS, 0) GlStateManager._pixelStore(GL_UNPACK_SKIP_ROWS, 0) GlStateManager._pixelStore(GL_UNPACK_ALIGNMENT, 4)

        this.context.resetAll()
    }
    
    fun postRender() {
        this.context.flush()
    
        //BufferUploader.reset()
    

    // glBindSampler(0, 0)

        GlStateManager._disableBlend()
        glDisable(GL_BLEND)
    
        GlStateManager._blendFuncSeparate(GL_SRC_ALPHA, GL_ONE, 0, 0)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE)
    
        //GlStateManager._blendEquation(GL_FUNC_ADD)
        glBlendEquation(GL_FUNC_ADD)
    
        GlStateManager._colorMask(true, true, true, true)
        glColorMask(true, true, true, true)
    
        GlStateManager._depthMask(true)
        glDepthMask(true)
    
        RenderSystem.disableScissor()
        glDisable(GL_SCISSOR_TEST)
        //ScissorStack.apply()
    
        glDisable(GL_STENCIL_TEST)
    
        GlStateManager._disableDepthTest()
        glDisable(GL_DEPTH_TEST)
    
        glActiveTexture(GL_TEXTURE0)
        GlStateManager._activeTexture(GL_TEXTURE0)
    
        GlStateManager._disableCull()
        glEnable(GL_CULL_FACE)
    }
    

    why doesnt this work for skiko on 1.21.5 minecraft after updating my mod from 1.21.4

  2. Assistant

    There are several factors that could be causing the state‑changes in your preRender/postRender methods to no longer work as expected when updating from 1.21.4 to 1.21.5. (Note that this isn’t necessarily a “bug” in Skiko but rather an integration issue between the mod’s OpenGL state management code and Minecraft’s updated render pipeline.) Here are some common reasons and suggestions for troubleshooting:

    1. Changes in Render Pipeline and Context Management:
      In recent Minecraft versions the render pipeline has evolved—especially with the integration of Skiko/Skia. In 1.21.5 the OpenGL (or Vulkan/Metal via Skia) context handling might be different from 1.21.4. If Skiko is now managing its own state more aggressively or even resetting GL state between phases, then your manual state tweaks (for blend modes, color masks, etc.) may be overwritten.

    2. Threading or Context Mismatch:
      Make sure that your calls to OpenGL (and the corresponding RenderSystem/GlStateManager calls) are executed on the correct render thread and within the proper context. It’s possible that in 1.21.5 the rendering thread or the timing of when the GL context is current has changed, so that your state changes are not applied where you expect them to be.

    3. Mixing Raw GL Calls and RenderSystem/GlStateManager Methods:
      You’re issuing both direct GL calls (like glDisable(GL_BLEND) and glBlendEquation(GL_FUNC_ADD)) as well as calls from GlStateManager. In previous versions this might have “worked” because the state machine was simpler and your code’s order took effect. In the updated version, however, Skiko or Minecraft’s internal RenderSystem might be resetting or reinterpreting these state changes. To fix this, try to consolidate your state manipulation through one system (preferably the one recommended by the latest changes, e.g. using RenderSystem or GlStateManager).

    4. Order of Operations:
      The order in which you disable features like blending, depth testing, and scissor tests may need to change to match the new expectations of the rendering pipeline. For example, if Skiko is performing its own flush or call to reinitialize state after your pre‑render step, then your modifications might never “stick” until after Skiko’s own state reset.

    5. Skiko’s Own State Management:
      Skiko/Skia sometimes “overrides” OpenGL state as part of its own drawing routines. It may be that in 1.21.5 the drawing routines reinitialize some states after your modifications. Check if there’s a new or recommended integration point (or API hook) for when you should apply your changes in the Skia/Skiko render flow.

    What to Try Next

    • Review the 1.21.5 Changelogs and Migration Guides:
      Look for any notes about changes in how OpenGL state is managed or how Skiko is integrated. There might be new recommended practices for mod developers.

    • Stick to a Single API for State Management:
      Instead of mixing direct GL calls with methods from RenderSystem or GlStateManager, see if you can use the recommended RenderSystem methods exclusively. This might ensure that your state changes survive any “internal” resets.

    • Confirm the GL Context and Thread:
      Double‑check that your preRender and postRender calls are happening on the correct thread and that the GL context you’re manipulating is indeed the one used by Skiko’s drawing layer.

    • Insert Debug Logging or Use a Debug Context:
      Consider logging the current state before and after your calls to see if something else is changing it afterward. In a debug GL context you might catch state changes or errors that aren’t obvious.

    In summary, the most likely causes are changes in how Minecraft’s updated rendering pipeline (via Skiko/Skia) manages the GL context and state as well as potential conflicts from mixing different state management calls. Adjusting your integration to follow the new guidelines and ensuring your changes are applied at the correct point in the render loop should help you resolve the issue.

  3. User

    most methods got removed from RenderSystem

  4. Assistant

    In Minecraft 1.21.5 many of the methods you were previously using from RenderSystem have been removed or made internal as part of Mojang’s effort to decouple mod code from internal rendering implementation details. This change is part of a broader effort to strengthen encapsulation and reduce the risk of mods interfering with the game’s internal render state management (especially given that Minecraft now more heavily integrates Skiko/Skia in the render pipeline). Here are some points to consider and approaches to resolve the issue:

    1. Encapsulation of the Render Pipeline:
      With newer releases, Mojang is moving toward a rendering pipeline that handles state changes internally. Removing many of the helper methods from RenderSystem is a design choice to force mod developers to avoid relying on internal state management routines which may change without notice.

    2. Relying Less on Internal State Management:
      Instead of trying to manually override or manipulate OpenGL state with calls to methods that are now removed, consider using the officially supported abstractions. Where possible, perform your rendering in isolated contexts (or layers) that do not confront the “global” state. This minimizes the risk of interferring with Minecraft’s own rendering cycles.

    3. Switching to Low-Level GL Calls Directly:
      If you really need to control OpenGL state, you may have to use raw OpenGL calls. However, be aware that this increases the risk of conflicts with Skiko/Skia. In those cases, ensure you’re setting your desired state in the correct phase of the rendering loop and that you’re not inadvertently overriding something that the internal pipeline expects.

    4. Review Modding Guidelines and API Updates:
      Check the official modding documentation or any migration guides for 1.21.5. Mojang or the modding community might have published updated recommendations on how to handle rendering now that several RenderSystem methods are no longer available.

    5. Implementing Bridges or Utility Layers:
      In some cases, you might need to create your own utility layer for managing OpenGL state. If you do this, be rigorous in resetting the state after you’re done to avoid side effects. Make sure your state changes are properly scoped so they can be undone as soon as your rendering for that frame concludes.

    6. Working in the Correct Context or Render Phase:
      Since Skiko uses its own context management, double‑check that your modifications are applied within the correct render cycle or context. Sometimes the removed methods are indicative of a deeper architectural shift that requires your code to run at a different point in the rendering process.

    Next Steps:

    • Update Your Rendering Code:
      Consider refactoring your pre‑render and post‑render code so that you rely solely on lower-level GL calls when absolutely necessary and let Minecraft handle as much as possible.

    • Test Extensively:
      Given the changes in the render system, ensure to test your mod under various conditions (including window resizing and different graphics settings) to catch any unforeseen issues.

    • Community and Documentation:
      Look for community examples or official announcements regarding 1.21.5 mod compatibility. Often, other mod developers may have documented their workarounds for similar issues.

    By understanding that these changes are intentional parts of the platform’s evolution, you can adjust your mod’s rendering strategy to be more stable and future-proof while complying with the new encapsulation boundaries set by Minecraft.

  5. User

    private fun makeSurface(width: Int = mc.window.framebufferWidth, height: Int = mc.window.framebufferHeight) { //println(glGetInteger(GL_DRAW_FRAMEBUFFER)) renderTarget = BackendRenderTarget.makeGL(width, height, 0, 8, glGenFramebuffers() /mc.framebuffer.fbo/, GL_RGBA8) surface = Surface.makeFromBackendRenderTarget(context, renderTarget, SurfaceOrigin.BOTTOM_LEFT, SurfaceColorFormat.RGBA_8888, ColorSpace.sRGB)!! canvas = surface.canvas }

    how would i just make a new framebuffer for this

  6. Assistant

    Below is an example approach in Kotlin that demonstrates how to create a new OpenGL framebuffer (FBO) manually and attach a color texture (and, optionally, a depth attachment) to it. This example uses raw OpenGL calls rather than relying on removed RenderSystem helper methods. You can adapt this code to your needs:

    Note: If you ultimately want to integrate this FBO with Skia/Skiko, you’d typically wrap the GL FBO with a backend render target—similar to your existing call to BackendRenderTarget.makeGL(...). The following example shows just the GL portion.


    Example: Creating a New Framebuffer

    import org.lwjgl.opengl.GL11.*
    import org.lwjgl.opengl.GL20.*
    import org.lwjgl.opengl.GL30.*
    
    // Create a new framebuffer and its attachments.
    fun createFramebuffer(width: Int, height: Int): FramebufferData {
        // 1. Generate and bind the framebuffer.
        val fbo = glGenFramebuffers()
        glBindFramebuffer(GL_FRAMEBUFFER, fbo)
    
        // 2. Create a color texture attachment.
        val colorTexture = glGenTextures()
        glBindTexture(GL_TEXTURE_2D, colorTexture)
        glTexImage2D(
            GL_TEXTURE_2D,
            0,
            GL_RGBA8,
            width,
            height,
            0,
            GL_RGBA,
            GL_UNSIGNED_BYTE,
            0 as Long
        )
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
        // Attach texture to framebuffer.
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0)
    
        // 3. (Optional) Create a depth (or depth-stencil) renderbuffer attachment.
        val depthRbo = glGenRenderbuffers()
        glBindRenderbuffer(GL_RENDERBUFFER, depthRbo)
        // For a depth attachment, use for example GL_DEPTH_COMPONENT24.
        // For depth-stencil, you might use GL_DEPTH24_STENCIL8.
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, width, height)
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRbo)
    
        // 4. Check framebuffer completeness.
        if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
            throw RuntimeException("Framebuffer is not complete!")
        }
    
        // 5. Unbind the framebuffer to restore default state.
        glBindFramebuffer(GL_FRAMEBUFFER, 0)
    
        return FramebufferData(
            fbo = fbo,
            colorTexture = colorTexture,
            depthRenderbuffer = depthRbo,
            width = width,
            height = height
        )
    }
    
    // Data class to store framebuffer attachments
    data class FramebufferData(
        val fbo: Int,
        val colorTexture: Int,
        val depthRenderbuffer: Int,
        val width: Int,
        val height: Int
    )
    

    Explanation

    1. Generate & Bind FBO:
      We start by generating a new framebuffer via glGenFramebuffers() and binding it with glBindFramebuffer(GL_FRAMEBUFFER, fbo).

    2. Create Color Texture Attachment:
      A new 2D texture is created using glGenTextures(), bound, and its data store allocated with glTexImage2D(...). Filtering parameters are set, and the texture is attached to the framebuffer as the color attachment with glFramebufferTexture2D(...).

    3. Create Depth Renderbuffer (Optional):
      For depth testing, a renderbuffer is created via glGenRenderbuffers(), bound, and storage allocated with glRenderbufferStorage(...). It is then attached as the depth attachment using glFramebufferRenderbuffer(...). If you need a depth‑stencil attachment, adjust the internal format (e.g., GL_DEPTH24_STENCIL8) and attachment point accordingly.

    4. Check Completeness:
      After all attachments are in place, call glCheckFramebufferStatus(GL_FRAMEBUFFER) to ensure the framebuffer is complete.

    5. Unbind FBO:
      Finally, unbind the framebuffer by binding to 0—this restores the default framebuffer for subsequent rendering calls.


    Integrating With Skia/Skiko

    If your goal is to create a Skia surface backed by your FBO, you can pass your framebuffer ID to Skia’s backend render target creation function, similar to:

    // Assuming you have a valid Skia Context (`context`).
    renderTarget = BackendRenderTarget.makeGL(
        width,
        height,
        0,       // sample count
        8,       // stencil bits or other settings, adjust as needed
        fbo,     // your newly created framebuffer ID,
        GL_RGBA8 // internal format
    )
    surface = Surface.makeFromBackendRenderTarget(
        context,
        renderTarget,
        SurfaceOrigin.BOTTOM_LEFT,
        SurfaceColorFormat.RGBA_8888,
        ColorSpace.sRGB
    ) ?: throw RuntimeException("Could not create Skia surface")
    canvas = surface.canvas
    

    This wraps your custom FBO so that Skia can draw onto it as a surface while Skiko manages the drawing.


    Final Notes

    • Context & Thread:
      Ensure that these OpenGL calls are made on the correct thread with the proper GL context current.

    • State Management:
      Remember to restore any changed state if your mod or Minecraft expects a specific configuration.

    • Cleanup:
      When your framebuffer or texture is no longer needed, make sure to delete them using glDeleteFramebuffers(), glDeleteTextures(), and glDeleteRenderbuffers() to free up resources.

    This approach gives you full control over creating and managing a framebuffer, and you can integrate it with Skia/Skiko as needed.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.