public Cell(GameObject cellGameObject, CellTexture cellTexture) { _cellGameObject = cellGameObject; CellName = cellGameObject.name; CellTexture = cellTexture; Position = cellGameObject.transform.localPosition; Scale = cellGameObject.transform.localScale; }
private void LoadBuffer() { for (uint i = 0; i < SizeY; i++) { for (uint j = 0; j < SizeX; j++) { Cell cell = cells[i, j]; if (cell == null) { continue; } cell.y = i; cell.x = j; field[i * SizeX + j] = new CellPoint { x = j, y = i, color = cell.Color, textureLayer = cell.TextureLayer }; } } fixed(void *pointer = field) { GL.BindBuffer(GL.ARRAY_BUFFER, vbo); GL.BindTexture(GL.TEXTURE_2D_ARRAY, textureId); GL.TexImage3D(GL.TEXTURE_2D_ARRAY, 0, GL.RGBA8, 16, 16, CellTextureManager.Textures.Count, 0, GL.BGRA, GL.UNSIGNED_BYTE, IntPtr.Zero); for (int i = 0; i < CellTextureManager.Textures.Count; i++) { CellTexture texture = CellTextureManager.Textures[i]; GL.TexSubImage3D(GL.TEXTURE_2D_ARRAY, 0, 0, 0, i, texture.Width, texture.Height, 1, GL.BGRA, GL.UNSIGNED_BYTE, texture.DataPointer); } GL.GenerateMipmap(GL.TEXTURE_2D_ARRAY); GL.BindTexture(GL.TEXTURE_2D_ARRAY, 0); GL.BufferData(GL.ARRAY_BUFFER, sizeof(CellPoint) * field.Length, pointer, GL.DYNAMIC_DRAW); GL.BindBuffer(GL.ARRAY_BUFFER, 0); } }
protected override void MouseDown(int button) { Texture = CellTexture.GetTexture("Resources\\clicked.png"); Console.WriteLine($"DOWN {x} {y}"); }