{"record":{"id":"2f117eaf6e854fb0","repo":"OpenRA/OpenRA","slug":"frame-buffer-size-size-width-x-size-height-mus","errorCode":null,"errorMessage":"Frame buffer size ({size.Width}x{size.Height}) must be a power of two","messagePattern":"Frame buffer size \\((.+?)x(.+?)\\) must be a power of two","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"OpenRA.Platforms.Default/FrameBuffer.cs","lineNumber":33,"sourceCode":"using OpenRA.Primitives;\n\nnamespace OpenRA.Platforms.Default\n{\n\tsealed class FrameBuffer : ThreadAffine, IFrameBuffer\n\t{\n\t\treadonly ITexture texture;\n\t\treadonly Size size;\n\t\treadonly Color clearColor;\n\t\tuint framebuffer, depth;\n\t\tbool disposed;\n\t\tbool scissored;\n\n\t\tpublic FrameBuffer(Size size, ITextureInternal texture, Color clearColor)\n\t\t{\n\t\t\tthis.size = size;\n\t\t\tthis.clearColor = clearColor;\n\t\t\tif (!Exts.IsPowerOf2(size.Width) || !Exts.IsPowerOf2(size.Height))\n\t\t\t\tthrow new InvalidDataException($\"Frame buffer size ({size.Width}x{size.Height}) must be a power of two\");\n\n\t\t\tOpenGL.glGenFramebuffers(1, out framebuffer);\n\t\t\tOpenGL.CheckGLError();\n\t\t\tOpenGL.glBindFramebuffer(OpenGL.GL_FRAMEBUFFER, framebuffer);\n\t\t\tOpenGL.CheckGLError();\n\n\t\t\t// Color\n\t\t\tthis.texture = texture;\n\t\t\ttexture.SetEmpty(size.Width, size.Height);\n\t\t\tOpenGL.glFramebufferTexture2D(OpenGL.GL_FRAMEBUFFER, OpenGL.GL_COLOR_ATTACHMENT0, OpenGL.GL_TEXTURE_2D, texture.ID, 0);\n\t\t\tOpenGL.CheckGLError();\n\n\t\t\t// Depth\n\t\t\tOpenGL.glGenRenderbuffers(1, out depth);\n\t\t\tOpenGL.CheckGLError();\n\n\t\t\tOpenGL.glBindRenderbuffer(OpenGL.GL_RENDERBUFFER, depth);\n\t\t\tOpenGL.CheckGLError();","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/OpenRA/OpenRA/blob/a520984d91eda9de48a62b1d15c1e3bad0d4fb1a/OpenRA.Platforms.Default/FrameBuffer.cs#L15-L51","documentation":"Thrown by the FrameBuffer constructor when either size.Width or size.Height is not a power of two (Exts.IsPowerOf2). The legacy GL framebuffer path requires power-of-two dimensions for the color texture and depth renderbuffer. InvalidDataException at construction time.","triggerScenarios":"Constructing a FrameBuffer with a Size whose width or height is e.g. 1920, 1080, 1366 — any non-PoT value — during renderer/window/sprite-buffer setup.","commonSituations":"A non-power-of-two display resolution or render target being passed in; a high-DPI/retina scale producing non-PoT backbuffer sizes; custom render targets with arbitrary dimensions; running on the default (non-NPOT) platform renderer.","solutions":["Pass power-of-two dimensions (e.g. 1024, 2048) to the FrameBuffer constructor.","Clamp the requested size up to the next power of two before constructing.","Use a renderer path that supports NPOT textures if the GPU allows it.","Check the caller supplying the Size (window/viewport setup) and round it to PoT."],"exampleFix":"// before\nvar fb = new FrameBuffer(new Size(width, height), texture, clearColor);\n// after - round up to next power of two\nint NextPoT(int v) { var p = 1; while (p < v) p <<= 1; return p; }\nvar fb = new FrameBuffer(new Size(NextPoT(width), NextPoT(height)), texture, clearColor);","handlingStrategy":"validation","validationCode":"if (!Exts.IsPowerOf2(size.Width) || !Exts.IsPowerOf2(size.Height))\n    throw new InvalidDataException(\n        $\"Frame buffer size ({size.Width}x{size.Height}) must be a power of two.\");","typeGuard":"static bool IsPoTSize(Size s) => Exts.IsPowerOf2(s.Width) && Exts.IsPowerOf2(s.Height);","tryCatchPattern":null,"preventionTips":["Round requested framebuffer dimensions up to the next power of two.","Avoid arbitrary display-resolution render targets on the PoT path.","Centralize PoT rounding in the renderer's buffer-allocation helper."],"tags":["opengl","graphics","framebuffer","power-of-two","config"],"backgroundTag":null,"analyzedSha":"a520984d91eda9de48a62b1d15c1e3bad0d4fb1a","analyzedAt":"2026-08-13T15:30:14.787Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}