JSFiddle - React, Tailwind, and code Playground

by arian_

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>GLSL Uniform Block Visualizer (std140)</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        textarea {
            width: 100%;
            height: 200px;
            font-family: monospace;
            font-size: 14px;
            padding: 10px;
            box-sizing: border-box;
        }
        button {
            margin-top: 10px;
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
        }
        .block-container {
            margin-top: 20px;
            border: 1px solid #ccc;
            padding: 10px;
            width: 600px;
            box-sizing: border-box;
        }
        .member, .padding {
            display: flex;
            justify-content: space-between;
            padding: 5px;
            border-bottom: 1px solid #eee;
        }
        .padding {
            background-color: #fdd;
            color: #900;
            font-style: italic;
        }
        .block-header, .block-footer {
            font-weight: bold;
            margin-bottom: 10px;
        }
        .total-size {
            margin-top: 10px;
            font-weight: bold;
        }
    </style>
</head>
<body>

<h1>GLSL Uniform Block Visualizer (std140)</h1>
<textarea id="uniformInput" placeholder="Enter your GLSL uniform block here...">
uniform MyUniformBlock {
    mat4 model;
    vec3 lightPosition;
    float intensity;
    int count;
    vec2 offsets[3];
};
</textarea>
<br>
<button onclick="visualizeUniform()">Visualize Uniform Block</button>

<div id="visualization" class="block-container"></div>

<script>
    // Define type sizes and alignments based on std140
    const typeInfo = {
        // Scalars
        'float': { size: 4, alignment: 4 },
        'int': { size: 4, alignment: 4 },
        'bool':...