<commit_before>//
// Created by Steven on 4/25/15.
//

#include "dangerengine.h"
#include <kazmath/kazmath.h>
#include <assert.h>

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif //__EMSCRIPTEN__

static inline void setup()
{
#ifdef __EMSCRIPTEN__
  EM_ASM({
    var canvas = document.getElementById('canvas');
    Module.canvas = canvas;
  });
#endif //__EMSCRIPTEN__
};

typedef struct {
  GLuint program;
  slsMesh *mesh;
} demoData;

void demo_context_setup(slsContext *self)
{
  sls_context_class()->setup(self);

  self->data = calloc(sizeof(demoData), 1);

  demoData *data = self->data;
  char const *vs_path = "resources/shaders/default.vert";
  char const *fs_path = "resources/shaders/default.frag";

  data->program = sls_create_program(vs_path, fs_path);

  slsVertex verts[] = {
    (slsVertex){.position={-1.0, -1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={0.0, 0.0}, .color={1.0, 1.0, 0.0, 1.0}},
    (slsVertex){.position={-1.0,  1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={0.0, 1.0}, .color={0.0, 1.0, 1.0, 1.0}},
    (slsVertex){.position={ 1.0,  1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={1.0, 1.0}, .color={1.0, 0.0, 1.0, 1.0}},
    (slsVertex){.position={ 1.0,  -1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={1.0, 0.0}, .color={1.0, 0.0, 1.0, 1.0}},
    (slsVertex){.position={ 1.0,  1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={1.0, 1.0}, .color={1.0, 0.0, 1.0, 1.0}},
    (slsVertex){.position={-1.0, -1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={0.0, 0.0}, .color={1.0, 1.0, 0.0, 1.0}},
  };

  sls_log_info("%lu", sizeof(verts));

  unsigned inds[] = {0, 1, 2, 3, 2, 0};
  data->mesh = sls_mesh_new(verts, sizeof(verts)/sizeof(slsVertex), inds, sizeof(inds)/sizeof(unsigned));
  sls_msg(data->mesh, bind, data->program);



  glClearColor(0.1, 0.24, 0.3, 1.0);
}

void demo_context_update(slsContext *self, double dt)
{
  demoData *data = self->data;
}

void demo_context_display(slsContext *self, double dt)
{
  demoData *data = self->data;

  GLint time = glGetUniformLocation(data->program, "time");

  float t = clock()/(float)CLOCKS_PER_SEC;
  glUniform1f(time, t);


  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


  glUseProgram(data->program);
  // setup vert position pointer

  glBindVertexArray(data->mesh->vao);


  glDrawArrays(GL_TRIANGLES, 0, 6);
  //glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, NULL);
  glBindVertexArray(0);

  glfwSwapBuffers(self->window);



}<commit_msg>modified exec.c<commit_after>//
// Created by Steven on 4/25/15.
//

#include "dangerengine.h"
#include <kazmath/kazmath.h>
#include <assert.h>

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif //__EMSCRIPTEN__

static inline void setup()
{
#ifdef __EMSCRIPTEN__
  EM_ASM({
    var canvas = document.getElementById('canvas');
    Module.canvas = canvas;
  });
#endif //__EMSCRIPTEN__
};

typedef struct {
  GLuint program;
  slsMesh *mesh;
} demoData;

void demo_context_setup(slsContext *self)
{
  sls_context_class()->setup(self);

  self->data = calloc(sizeof(demoData), 1);

  demoData *data = self->data;
  char const *vs_path = "resources/shaders/default.vert";
  char const *fs_path = "resources/shaders/default.frag";

  data->program = sls_create_program(vs_path, fs_path);

  slsVertex verts[] = {
    (slsVertex){.position={-1.0, -1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={0.0, 0.0}, .color={1.0, 1.0, 0.0, 1.0}},
    (slsVertex){.position={-1.0,  1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={0.0, 1.0}, .color={0.0, 1.0, 1.0, 1.0}},
    (slsVertex){.position={ 1.0,  1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={1.0, 1.0}, .color={1.0, 0.0, 1.0, 1.0}},
    (slsVertex){.position={ 1.0,  -1.0, 0.0}, .normal={0.0, 0.0, 1.0}, .uv={1.0, 0.0}, .color={1.0, 0.0, 1.0, 1.0}}
  };

  sls_log_info("%lu", sizeof(verts));

  unsigned inds[] = {0, 1, 2, 3, 2, 0};
  data->mesh = sls_mesh_new(verts, sizeof(verts)/sizeof(slsVertex), inds, sizeof(inds)/sizeof(unsigned));
  sls_msg(data->mesh, bind, data->program);



  glClearColor(0.1, 0.24, 0.3, 1.0);
}

void demo_context_update(slsContext *self, double dt)
{
  demoData *data = self->data;
}

void demo_context_display(slsContext *self, double dt)
{
  demoData *data = self->data;

  GLint time = glGetUniformLocation(data->program, "time");

  float t = clock()/(float)CLOCKS_PER_SEC;
  glUniform1f(time, t);


  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


  glUseProgram(data->program);
  // setup vert position pointer

  glBindVertexArray(data->mesh->vao);


  glDrawElements(GL_TRIANGLES, 4, GL_UNSIGNED_INT, NULL);
  glBindVertexArray(0);

  glfwSwapBuffers(self->window);



}
{'fraction_non_alphanumeric': 0.21000658327847269, 'fraction_numerical': 0.06363835856923415, 'mean_word_length': 3.8181818181818183, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5948555', 'n_tokens_mistral': 2120, 'n_tokens_neox': 1956, 'n_words': 375}