diff options
| author | 2019-08-19 15:53:22 -0400 | |
|---|---|---|
| committer | 2019-08-19 15:53:22 -0400 | |
| commit | d64514659c38c672e65ffccd6f44a64143a4dbfd (patch) | |
| tree | e1704f5b1d0c7784991da6c18d6b520ec1e08e65 /frontends/gl | |
| parent | 9298c0795c9ffba2fa804290df3792c437d3c500 (diff) | |
| download | cetris-d64514659c38c672e65ffccd6f44a64143a4dbfd.tar.gz cetris-d64514659c38c672e65ffccd6f44a64143a4dbfd.tar.bz2 cetris-d64514659c38c672e65ffccd6f44a64143a4dbfd.zip | |
remove das code and simplify some other stuff
Diffstat (limited to 'frontends/gl')
| -rw-r--r-- | frontends/gl/main.c | 29 | ||||
| -rw-r--r-- | frontends/gl/res/play_field.png | bin | 0 -> 814 bytes | |||
| -rw-r--r-- | frontends/gl/res/play_field_shake_1.png | bin | 0 -> 9007 bytes | |||
| -rw-r--r-- | frontends/gl/res/play_field_shake_2.png | bin | 0 -> 10769 bytes | |||
| -rw-r--r-- | frontends/gl/res/play_field_shake_3.png | bin | 0 -> 9551 bytes | |||
| -rw-r--r-- | frontends/gl/res/play_field_shake_4.png | bin | 0 -> 9954 bytes |
6 files changed, 22 insertions, 7 deletions
diff --git a/frontends/gl/main.c b/frontends/gl/main.c index 01da0c9..87cbd19 100644 --- a/frontends/gl/main.c +++ b/frontends/gl/main.c @@ -64,12 +64,12 @@ rbg_color colors[8] = { {0.255f,0.220f,0.0f} // Yellow
};
-struct block_drawable {
+typedef struct {
GLuint vao;
GLuint vbo;
GLuint ebo;
GLuint texture;
-};
+} drawable;
void framebuffer_size_callback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
@@ -113,7 +113,7 @@ void load_fragment_shader(GLuint program) { glDeleteShader(fragment_shader);
}
-void create_block(struct block_drawable *b) {
+void create_static_2d(drawable *b, int w, int h, char* texture_file) {
glGenVertexArrays(1, &b->vao);
glGenBuffers(1, &b->vbo);
glGenBuffers(1, &b->ebo);
@@ -124,6 +124,9 @@ void create_block(struct block_drawable *b) { glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, b->vbo);
+
+ GLfloat rect[32];
+ memcpy(&rect, &default_rect, sizeof(GLfloat) * 32);
glBufferData(GL_ARRAY_BUFFER, 32 * sizeof(GLfloat), default_rect, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)0);
@@ -135,10 +138,18 @@ void create_block(struct block_drawable *b) { glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(GLfloat), (void*)(6 * sizeof(GLfloat)));
glEnableVertexAttribArray(2);
- load_texture("block.jpg", b->texture);
+ load_texture(texture_file, b->texture);
+}
+
+void calc_size(GLfloat *rect, int x, int y) {
+ rect[0] = rect[8] = (x + 1.0f) / 10.0f;
+ rect[1] = rect[25] = (((y) * -1.0f) + 1.0f) / 20.0f;
+ rect[9] = rect[17] = rect[1] - .05f;
+ rect[16] = rect[24] = rect[0] - .1f;
}
-void update_block(struct block_drawable *b, int x, int y, int color) {
+
+void update_block(drawable *b, int x, int y, int color) {
GLfloat block[32];
memcpy(block, default_rect, sizeof(GLfloat) * 32);
@@ -185,8 +196,12 @@ int main(void) { load_vertex_shader(shader_program);
glLinkProgram(shader_program);
- struct block_drawable block;
- create_block(&block);
+ drawable block;
+ create_static_2d(&block, 124, 124, "block.jpg");
+
+ drawable play_field;
+
+
cetris_game cetris;
init_game(&cetris);
diff --git a/frontends/gl/res/play_field.png b/frontends/gl/res/play_field.png Binary files differnew file mode 100644 index 0000000..dee673b --- /dev/null +++ b/frontends/gl/res/play_field.png diff --git a/frontends/gl/res/play_field_shake_1.png b/frontends/gl/res/play_field_shake_1.png Binary files differnew file mode 100644 index 0000000..4bbd0fb --- /dev/null +++ b/frontends/gl/res/play_field_shake_1.png diff --git a/frontends/gl/res/play_field_shake_2.png b/frontends/gl/res/play_field_shake_2.png Binary files differnew file mode 100644 index 0000000..a5d5c20 --- /dev/null +++ b/frontends/gl/res/play_field_shake_2.png diff --git a/frontends/gl/res/play_field_shake_3.png b/frontends/gl/res/play_field_shake_3.png Binary files differnew file mode 100644 index 0000000..e26c21e --- /dev/null +++ b/frontends/gl/res/play_field_shake_3.png diff --git a/frontends/gl/res/play_field_shake_4.png b/frontends/gl/res/play_field_shake_4.png Binary files differnew file mode 100644 index 0000000..399ecb8 --- /dev/null +++ b/frontends/gl/res/play_field_shake_4.png |