<commit_before>package glsl

import com.jogamp.opengl.GL2ES2
import com.jogamp.opengl.util.glsl.ShaderCode

/**
 * Created by GBarbieri on 21.02.2017.
 */

fun shaderCodeOf(string: String, gl: GL2ES2, context: Class<*>): ShaderCode = ShaderCode.create(gl, string.type, context::class.java,
        if (string.contains('/')) string.substringAfterLast('/') else "", null, string, "vert", null, true)


/**
 * https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
 *
 * .vert - a vertex shader
 * .tesc - a tessellation control shader
 * .tese - a tessellation evaluation shader
 * .geom - a geometry shader
 * .frag - a fragment shader
 * .comp - a compute shader     */
internal val String.type
    get() = when (substring(lastIndexOf('.') + 1)) {
        "vert" -> com.jogamp.opengl.GL2ES2.GL_VERTEX_SHADER
        "tesc" -> com.jogamp.opengl.GL3ES3.GL_TESS_CONTROL_SHADER
        "tese" -> com.jogamp.opengl.GL3ES3.GL_TESS_EVALUATION_SHADER
        "geom" -> com.jogamp.opengl.GL3ES3.GL_GEOMETRY_SHADER
        "frag" -> com.jogamp.opengl.GL2ES2.GL_FRAGMENT_SHADER
        "comp" -> com.jogamp.opengl.GL3ES3.GL_COMPUTE_SHADER
        else -> throw Error("invalid shader extension")
    }<commit_msg>maybe<commit_after>package glsl

import com.jogamp.opengl.GL2ES2
import com.jogamp.opengl.GL2ES2.GL_VERTEX_SHADER
import com.jogamp.opengl.GL3ES3.*
import com.jogamp.opengl.util.glsl.ShaderCode

/**
 * Created by GBarbieri on 21.02.2017.
 */

/**
 * https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
 *
 * .vert - a vertex shader
 * .tesc - a tessellation control shader
 * .tese - a tessellation evaluation shader
 * .geom - a geometry shader
 * .frag - a fragment shader
 * .comp - a compute shader
 * */
fun shaderCodeOf(string: String, gl: GL2ES2, context: Class<*>): ShaderCode =
        ShaderCode.create(
                gl,
                when (string.substringAfterLast('.')) { // type
                    "vert" -> GL_VERTEX_SHADER
                    "tesc" -> GL_TESS_CONTROL_SHADER
                    "tese" -> GL_TESS_EVALUATION_SHADER
                    "geom" -> GL_GEOMETRY_SHADER
                    "frag" -> GL_FRAGMENT_SHADER
                    "comp" -> GL_COMPUTE_SHADER
                    else -> throw Error("invalid shader extension")
                },
                context,
                if (string.contains('/')) string.substringBeforeLast('/') else "", // root
                null, // binary root
                string.substringAfterLast('/').substringBefore('.'), // src
                string.substringAfterLast('.'), // extension
                null, // binary extension
                true)   // mutable builder

{'fraction_non_alphanumeric': 0.1297539149888143, 'fraction_numerical': 0.015287099179716629, 'mean_word_length': 2.296068796068796, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3727417', 'n_tokens_mistral': 933, 'n_tokens_neox': 895, 'n_words': 173}