TileLayer doesn't get any texture when assigned manually #254

Open
opened 2026-03-03 22:23:51 +00:00 by john · 0 comments
Owner

while analyzing my 7DRL entry:

● Found it. Here's the diagnosis:                                                                                                                                            
                                                                                                                                                                             
  The problem is in zone.py line 151-153. When you explicitly pass a layers tuple to the Grid constructor, the code takes the path at line 933 (explicit layers), not the    
  default path at line 930-932.                                                                                                                                              
                                                                                                                                                                             
  In the default path (no layers argument), the Grid creates a TileLayer and passes it texture_ptr — the Grid's own texture:                                                 
  # line 932: self->data->addTileLayer(-1, texture_ptr, "tilesprite");                                                                                                     

  But in the explicit layers path (lines 1023-1082), the code just takes the TileLayer objects you already constructed and attaches them as-is. It never assigns the Grid's
  texture to the TileLayer.

  Look at your debug_house procgen:
  ground = mcrfpy.TileLayer(name="ground", z_index=-3)   # <-- no texture!
  grid = mcrfpy.Grid(grid_size=(...), texture=dungeon_tex, layers=(ground,))

  The TileLayer is created with no texture, and the Grid doesn't propagate its texture kwarg to the explicit layers. So ground.texture is None, and
  TileLayer::renderChunkToTexture bails out at line 589: if (!texture) return;.

  Fix: pass the texture to the TileLayer directly:
  ground = mcrfpy.TileLayer(name="ground", z_index=-3, texture=dungeon_tex)

  The Grid's texture kwarg only matters for the default auto-created TileLayer (when you don't pass layers at all). When you supply your own layers, each TileLayer needs its
   own texture.

Probably, TileLayer with no texture should defer to the Grid texture? The default action of using the Grid's own texture to initialize tilesprite by default can be replaced with this no-texture behavior.

while analyzing my 7DRL entry: ``` ● Found it. Here's the diagnosis: The problem is in zone.py line 151-153. When you explicitly pass a layers tuple to the Grid constructor, the code takes the path at line 933 (explicit layers), not the default path at line 930-932. In the default path (no layers argument), the Grid creates a TileLayer and passes it texture_ptr — the Grid's own texture: # line 932: self->data->addTileLayer(-1, texture_ptr, "tilesprite"); But in the explicit layers path (lines 1023-1082), the code just takes the TileLayer objects you already constructed and attaches them as-is. It never assigns the Grid's texture to the TileLayer. Look at your debug_house procgen: ground = mcrfpy.TileLayer(name="ground", z_index=-3) # <-- no texture! grid = mcrfpy.Grid(grid_size=(...), texture=dungeon_tex, layers=(ground,)) The TileLayer is created with no texture, and the Grid doesn't propagate its texture kwarg to the explicit layers. So ground.texture is None, and TileLayer::renderChunkToTexture bails out at line 589: if (!texture) return;. Fix: pass the texture to the TileLayer directly: ground = mcrfpy.TileLayer(name="ground", z_index=-3, texture=dungeon_tex) The Grid's texture kwarg only matters for the default auto-created TileLayer (when you don't pass layers at all). When you supply your own layers, each TileLayer needs its own texture. ``` Probably, `TileLayer` with no texture should defer to the `Grid` texture? The default action of using the Grid's own texture to initialize `tilesprite` by default can be replaced with this no-texture behavior.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#254
No description provided.