summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-10-10 16:23:26 +0200
committerMel <einebeere@gmail.com>2022-10-10 16:23:26 +0200
commitcb3ddae385c03a8830d39dc37fcd5bf273524d5e (patch)
tree0ccddcd6b32838b8fc2b65805a4fba96c4c0ff39
parent799c06e0387e01bdb8a10019be6192f9db00a824 (diff)
downloadmeowcraft-cb3ddae385c03a8830d39dc37fcd5bf273524d5e.tar.zst
meowcraft-cb3ddae385c03a8830d39dc37fcd5bf273524d5e.zip
Try to add second VBO
-rw-r--r--.gitignore2
-rw-r--r--assets/images/atlas.pngbin0 -> 1971 bytes
-rw-r--r--assets/images/atlas.ppm3076
-rw-r--r--assets/shaders/fragment.glsl5
-rw-r--r--assets/shaders/vertex.glsl4
-rw-r--r--src/Binder.cpp6
-rw-r--r--src/Image/PPMParser.cpp11
-rw-r--r--src/Image/RawImage.cpp16
-rw-r--r--src/Image/RawImage.hpp15
-rw-r--r--src/Mesh.cpp8
-rw-r--r--src/Mesh.hpp8
-rw-r--r--src/Texture.cpp27
-rw-r--r--src/Texture.hpp17
-rw-r--r--src/main.cpp9
14 files changed, 3182 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore
index b01afd5..4418da3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
cmake-build-debug
.idea
-src/Shader/Generated \ No newline at end of file
+assets/generated \ No newline at end of file
diff --git a/assets/images/atlas.png b/assets/images/atlas.png
new file mode 100644
index 0000000..b407403
--- /dev/null
+++ b/assets/images/atlas.png
Binary files differ
diff --git a/assets/images/atlas.ppm b/assets/images/atlas.ppm
new file mode 100644
index 0000000..1cb42cf
--- /dev/null
+++ b/assets/images/atlas.ppm
@@ -0,0 +1,3076 @@
+P3
+# Meowcraft atlas.ppm
+32 32
+255
+129
+151
+53
+124
+147
+49
+124
+147
+49
+102
+127
+30
+102
+127
+30
+129
+151
+53
+129
+151
+53
+109
+134
+36
+107
+133
+35
+123
+147
+49
+129
+151
+53
+129
+151
+53
+129
+151
+53
+129
+151
+53
+129
+151
+53
+129
+151
+53
+105
+60
+40
+105
+60
+40
+93
+54
+35
+93
+54
+35
+93
+54
+35
+80
+46
+27
+68
+36
+20
+116
+71
+49
+118
+72
+51
+118
+72
+51
+105
+60
+40
+105
+60
+40
+93
+54
+35
+93
+54
+35
+105
+60
+40
+100
+56
+37
+129
+151
+53
+124
+147
+49
+124
+147
+49
+102
+127
+30
+102
+127
+30
+129
+151
+53
+129
+151
+53
+109
+134
+36
+116
+140
+41
+110
+135
+36
+109
+134
+36
+103
+129
+32
+129
+151
+53
+129
+151
+53
+107
+132
+34
+129
+151
+53
+68
+36
+20
+67
+36
+19
+80
+46
+27
+93
+54
+35
+93
+54
+35
+66
+35
+19
+59
+30
+15
+93
+57
+36
+105
+60
+40
+105
+60
+40
+105
+60
+40
+105
+60
+40
+79
+42
+25
+81
+44
+27
+66
+35
+19
+66
+35
+19
+129
+151
+53
+124
+147
+49
+124
+147
+49
+124
+147
+49
+98
+124
+28
+129
+151
+53
+129
+151
+53
+129
+151
+53
+129
+151
+53
+109
+134
+36
+112
+137
+39
+107
+133
+35
+91
+115
+25
+115
+139
+40
+129
+151
+53
+129
+151
+53
+93
+54
+35
+91
+47
+29
+66
+35
+19
+80
+46
+27
+105
+60
+40
+105
+60
+40
+79
+42
+25
+81
+44
+27
+68
+36
+20
+105
+60
+40
+105
+60
+40
+79
+42
+25
+79
+42
+25
+81
+44
+27
+80
+46
+27
+80
+46
+27
+124
+146
+48
+124
+147
+49
+124
+146
+48
+158
+184
+60
+103
+129
+32
+98
+124
+28
+129
+151
+53
+124
+147
+49
+129
+151
+53
+129
+151
+53
+129
+151
+53
+127
+149
+51
+91
+115
+25
+103
+129
+33
+103
+129
+32
+124
+147
+49
+118
+72
+51
+105
+60
+40
+91
+47
+29
+79
+42
+25
+105
+60
+40
+105
+60
+40
+93
+54
+35
+81
+44
+27
+79
+42
+25
+66
+35
+19
+60
+31
+16
+66
+35
+19
+80
+46
+27
+80
+46
+27
+80
+46
+27
+93
+54
+35
+123
+146
+48
+123
+146
+48
+158
+184
+60
+127
+149
+51
+100
+125
+30
+158
+184
+60
+91
+115
+25
+127
+149
+51
+129
+151
+53
+124
+147
+49
+129
+151
+53
+129
+151
+53
+129
+151
+53
+107
+132
+35
+98
+124
+29
+119
+142
+44
+118
+72
+51
+105
+60
+40
+105
+60
+40
+79
+42
+25
+68
+36
+20
+93
+54
+35
+93
+54
+35
+93
+54
+35
+93
+54
+35
+83
+46
+29
+64
+34
+18
+88
+50
+32
+93
+54
+35
+93
+54
+35
+89
+54
+33
+114
+69
+48
+129
+151
+53
+124
+146
+48
+123
+146
+48
+112
+136
+39
+158
+184
+60
+95
+121
+28
+108
+134
+36
+109
+134
+36
+129
+151
+53
+124
+147
+49
+129
+151
+53
+129
+151
+53
+129
+151
+53
+129
+151
+53
+104
+129
+32
+103
+129
+32
+105
+60
+40
+105
+60
+40
+93
+54
+35
+80
+46
+27
+66
+35
+19
+80
+46
+27
+118
+72
+51
+105
+60
+40
+93
+54
+35
+80
+43
+26
+66
+35
+19
+93
+54
+35
+93
+54
+35
+93
+54
+35
+107
+62
+42
+107
+62
+42
+108
+133
+35
+108
+133
+35
+109
+134
+36
+127
+149
+51
+119
+142
+44
+127
+149
+51
+91
+115
+25
+91
+115
+25
+124
+147
+49
+124
+147
+49
+124
+147
+49
+129
+151
+53
+129
+151
+53
+129
+151
+53
+129
+151
+53
+109
+134
+36
+105
+60
+40
+93
+54
+35
+66
+35
+19
+66
+35
+19
+68
+36
+20
+106
+61
+41
+118
+72
+51
+105
+60
+40
+105
+60
+40
+71
+38
+21
+67
+35
+19
+93
+54
+35
+93
+54
+35
+93
+54
+35
+93
+54
+35
+105
+60
+40
+125
+148
+50
+105
+130
+33
+104
+129
+32
+109
+134
+36
+129
+151
+53
+129
+151
+53
+123
+147
+49
+91
+115
+25
+91
+115
+25
+107
+132
+35
+99
+124
+30
+124
+147
+49
+111
+136
+38
+127
+149
+51
+125
+148
+50
+128
+150
+52
+91
+52
+34
+71
+38
+21
+81
+44
+27
+88
+50
+32
+93
+54
+35
+105
+60
+40
+105
+60
+40
+105
+60
+40
+105
+60
+40
+93
+54
+35
+80
+46
+27
+111
+66
+45
+111
+66
+45
+93
+54
+35
+93
+54
+35
+93
+54
+35
+129
+151
+53
+129
+151
+53
+103
+129
+32
+91
+115
+25
+129
+151
+53
+124
+147
+49
+124
+147
+49
+127
+149
+51
+116
+140
+42
+102
+127
+31
+101
+127
+31
+105
+130
+34
+115
+139
+41
+107
+133
+35
+112
+136
+38
+102
+128
+31
+78
+44
+26
+107
+62
+42
+111
+66
+45
+105
+60
+40
+93
+54
+35
+93
+54
+35
+105
+60
+40
+105
+60
+40
+93
+54
+35
+93
+54
+35
+105
+60
+40
+111
+66
+45
+111
+66
+45
+105
+60
+40
+93
+54
+35
+87
+49
+31
+129
+151
+53
+129
+151
+53
+109
+134
+36
+91
+115
+25
+124
+147
+49
+124
+147
+49
+107
+132
+34
+129
+151
+53
+129
+151
+53
+129
+151
+53
+124
+146
+48
+113
+137
+40
+113
+137
+39
+124
+147
+49
+124
+147
+49
+127
+150
+52
+80
+46
+27
+118
+72
+51
+117
+71
+50
+105
+60
+40
+93
+54
+35
+93
+54
+35
+93
+54
+35
+71
+38
+21
+91
+52
+34
+93
+54
+35
+109
+64
+44
+118
+72
+51
+105
+60
+40
+105
+60
+40
+93
+54
+35
+60
+31
+16
+129
+151
+53
+129
+151
+53
+109
+134
+36
+107
+132
+35
+123
+146
+48
+107
+132
+34
+107
+132
+34
+129
+151
+53
+124
+147
+49
+128
+150
+53
+124
+147
+49
+123
+146
+48
+158
+184
+60
+129
+151
+53
+129
+151
+53
+129
+151
+53
+71
+38
+21
+100
+56
+37
+105
+60
+40
+95
+56
+37
+107
+62
+42
+105
+60
+40
+80
+46
+27
+66
+35
+19
+87
+49
+31
+93
+54
+35
+93
+54
+35
+105
+60
+40
+105
+60
+40
+105
+60
+40
+66
+35
+19
+66
+35
+19
+129
+151
+53
+109
+134
+36
+109
+134
+36
+129
+151
+53
+123
+146
+48
+107
+132
+34
+118
+142
+42
+103
+129
+32
+104
+129
+33
+124
+147
+49
+117
+141
+43
+158
+184
+60
+129
+151
+53
+129
+151
+53
+158
+184
+60
+129
+151
+53
+71
+38
+21
+66
+35
+19
+80
+46
+27
+114
+69
+48
+114
+69
+48
+105
+60
+40
+105
+60
+40
+66
+35
+19
+80
+43
+26
+93
+54
+35
+93
+54
+35
+93
+54
+35
+105
+60
+40
+66
+35
+19
+80
+43
+26
+93
+54
+35
+109
+134
+36
+107
+132
+35
+124
+147
+49
+123
+146
+48
+100
+126
+31
+108
+132
+34
+107
+132
+34
+94
+119
+26
+91
+115
+25
+91
+115
+25
+88
+113
+22
+112
+137
+39
+117
+141
+43
+158
+184
+60
+117
+141
+43
+97
+123
+28
+81
+44
+27
+68
+36
+20
+117
+71
+50
+118
+72
+51
+105
+60
+40
+105
+60
+40
+80
+46
+27
+68
+36
+20
+68
+36
+20
+79
+42
+25
+93
+54
+35
+93
+54
+35
+81
+44
+27
+66
+35
+19
+93
+54
+35
+93
+54
+35
+123
+146
+48
+123
+146
+48
+123
+146
+48
+103
+129
+32
+113
+138
+40
+114
+138
+40
+109
+134
+36
+124
+147
+49
+109
+134
+36
+107
+132
+35
+103
+129
+32
+102
+127
+31
+101
+127
+31
+101
+127
+31
+107
+132
+35
+107
+132
+35
+93
+54
+35
+84
+46
+28
+118
+72
+51
+105
+60
+40
+105
+60
+40
+93
+54
+35
+81
+44
+27
+79
+42
+25
+76
+43
+24
+66
+35
+19
+66
+35
+19
+66
+35
+19
+66
+35
+19
+68
+36
+20
+105
+60
+40
+105
+60
+40
+129
+151
+53
+129
+151
+53
+125
+148
+50
+95
+121
+26
+103
+128
+31
+129
+151
+53
+129
+151
+53
+124
+147
+49
+107
+132
+34
+129
+151
+53
+129
+151
+53
+109
+134
+36
+107
+132
+35
+107
+132
+35
+123
+146
+48
+129
+151
+53
+105
+60
+40
+79
+42
+25
+100
+56
+37
+105
+60
+40
+105
+60
+40
+93
+54
+35
+79
+42
+25
+100
+56
+37
+118
+72
+51
+105
+60
+40
+76
+43
+24
+93
+54
+35
+93
+54
+35
+105
+60
+40
+117
+71
+50
+105
+60
+40
+129
+151
+53
+129
+151
+53
+119
+143
+44
+98
+124
+28
+128
+150
+52
+129
+151
+53
+129
+151
+53
+107
+132
+34
+107
+132
+34
+129
+151
+53
+129
+151
+53
+129
+151
+53
+107
+132
+34
+129
+151
+53
+129
+151
+53
+129
+151
+53
+105
+60
+40
+66
+35
+19
+76
+43
+24
+93
+54
+35
+93
+54
+35
+88
+50
+32
+79
+42
+25
+105
+60
+40
+116
+71
+49
+105
+60
+40
+105
+60
+40
+93
+54
+35
+93
+54
+35
+105
+60
+40
+105
+60
+40
+105
+60
+40
+129
+151
+53
+129
+151
+53
+127
+149
+51
+109
+133
+36
+124
+147
+49
+124
+147
+49
+129
+151
+53
+129
+151
+53
+109
+133
+36
+129
+151
+53
+129
+151
+53
+129
+151
+53
+109
+133
+36
+129
+151
+53
+129
+151
+53
+129
+151
+53
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+129
+151
+53
+129
+151
+53
+113
+138
+40
+109
+133
+36
+113
+136
+39
+110
+133
+37
+124
+146
+48
+129
+151
+53
+109
+133
+36
+129
+151
+53
+129
+151
+53
+129
+151
+53
+109
+133
+36
+125
+148
+50
+129
+151
+53
+129
+151
+53
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+129
+151
+53
+127
+149
+51
+111
+134
+38
+97
+122
+28
+113
+136
+38
+99
+123
+28
+107
+129
+35
+129
+151
+53
+109
+133
+36
+122
+146
+48
+128
+150
+52
+125
+148
+50
+128
+150
+52
+115
+138
+42
+121
+143
+45
+129
+151
+53
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+129
+151
+53
+129
+151
+53
+114
+137
+40
+95
+121
+27
+108
+132
+36
+65
+29
+15
+86
+109
+22
+119
+142
+45
+91
+115
+25
+102
+126
+32
+120
+142
+44
+109
+134
+36
+124
+146
+48
+88
+113
+23
+106
+131
+34
+129
+151
+53
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+129
+151
+53
+123
+146
+48
+111
+135
+38
+79
+102
+17
+91
+117
+25
+65
+32
+18
+64
+89
+12
+85
+110
+21
+67
+92
+13
+93
+117
+27
+102
+126
+32
+97
+124
+28
+109
+134
+37
+85
+108
+21
+82
+108
+19
+125
+147
+49
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+123
+146
+48
+118
+141
+44
+101
+127
+33
+77
+102
+17
+51
+25
+11
+49
+23
+11
+62
+25
+14
+64
+90
+12
+37
+59
+3
+72
+97
+14
+74
+100
+15
+65
+32
+18
+88
+112
+22
+61
+86
+11
+74
+100
+15
+109
+133
+37
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+100
+124
+30
+91
+115
+25
+80
+104
+19
+55
+27
+14
+56
+27
+14
+98
+54
+34
+95
+49
+32
+66
+28
+17
+79
+38
+21
+52
+23
+11
+42
+18
+7
+63
+30
+18
+63
+28
+16
+38
+58
+3
+77
+101
+17
+92
+118
+25
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+83
+108
+20
+87
+112
+22
+64
+31
+17
+82
+45
+28
+87
+49
+31
+105
+60
+40
+105
+60
+40
+105
+60
+40
+105
+60
+40
+91
+52
+34
+78
+44
+26
+99
+55
+35
+87
+45
+26
+69
+35
+20
+84
+109
+21
+82
+107
+19
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+55
+27
+13
+78
+38
+22
+97
+54
+34
+103
+58
+39
+93
+54
+35
+93
+54
+35
+105
+60
+40
+105
+60
+40
+93
+54
+35
+93
+54
+35
+105
+60
+40
+111
+66
+45
+109
+64
+43
+94
+50
+32
+65
+33
+19
+55
+25
+13
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+72
+40
+22
+113
+67
+46
+117
+71
+50
+105
+60
+40
+93
+54
+35
+93
+54
+35
+93
+54
+35
+71
+38
+21
+91
+52
+34
+93
+54
+35
+109
+64
+44
+118
+72
+51
+105
+60
+40
+105
+60
+40
+93
+54
+35
+66
+35
+19
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+71
+38
+21
+100
+56
+37
+105
+60
+40
+95
+56
+37
+107
+62
+42
+105
+60
+40
+80
+46
+27
+66
+35
+19
+87
+49
+31
+93
+54
+35
+93
+54
+35
+105
+60
+40
+105
+60
+40
+105
+60
+40
+66
+35
+19
+66
+35
+19
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+71
+38
+21
+66
+35
+19
+80
+46
+27
+114
+69
+48
+114
+69
+48
+105
+60
+40
+105
+60
+40
+66
+35
+19
+80
+43
+26
+93
+54
+35
+93
+54
+35
+93
+54
+35
+105
+60
+40
+66
+35
+19
+80
+43
+26
+93
+54
+35
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+81
+44
+27
+68
+36
+20
+117
+71
+50
+118
+72
+51
+105
+60
+40
+105
+60
+40
+80
+46
+27
+68
+36
+20
+68
+36
+20
+79
+42
+25
+93
+54
+35
+93
+54
+35
+81
+44
+27
+66
+35
+19
+93
+54
+35
+93
+54
+35
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+93
+54
+35
+84
+46
+28
+118
+72
+51
+105
+60
+40
+105
+60
+40
+93
+54
+35
+81
+44
+27
+79
+42
+25
+76
+43
+24
+66
+35
+19
+66
+35
+19
+66
+35
+19
+66
+35
+19
+68
+36
+20
+105
+60
+40
+105
+60
+40
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+105
+60
+40
+79
+42
+25
+100
+56
+37
+105
+60
+40
+105
+60
+40
+93
+54
+35
+79
+42
+25
+100
+56
+37
+118
+72
+51
+105
+60
+40
+76
+43
+24
+93
+54
+35
+93
+54
+35
+105
+60
+40
+117
+71
+50
+105
+60
+40
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+105
+60
+40
+66
+35
+19
+76
+43
+24
+93
+54
+35
+93
+54
+35
+88
+50
+32
+79
+42
+25
+105
+60
+40
+116
+71
+49
+105
+60
+40
+105
+60
+40
+93
+54
+35
+93
+54
+35
+105
+60
+40
+105
+60
+40
+105
+60
+40
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
+255
diff --git a/assets/shaders/fragment.glsl b/assets/shaders/fragment.glsl
index ba5ed93..debc145 100644
--- a/assets/shaders/fragment.glsl
+++ b/assets/shaders/fragment.glsl
@@ -1,7 +1,10 @@
#version 330 core
+in vec2 frag_tex_coord;
+
out vec4 color;
void main() {
- color = vec4(0.2f, 0.6f, 0.6f, 1.0f); // #339999
+ //color = vec4(0.2f, 0.6f, 0.6f, 1.0f); // #339999
+ color = vec4(frag_tex_coord.xy, 1.0f, 1.0f);
} \ No newline at end of file
diff --git a/assets/shaders/vertex.glsl b/assets/shaders/vertex.glsl
index e7b9e3d..4faca1a 100644
--- a/assets/shaders/vertex.glsl
+++ b/assets/shaders/vertex.glsl
@@ -5,7 +5,11 @@ uniform mat4 view_matrix;
uniform mat4 projection_matrix;
in vec3 position;
+in vec2 tex_coord;
+
+out vec2 frag_tex_coord;
void main() {
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(position, 1.0);
+ frag_tex_coord = tex_coord;
} \ No newline at end of file
diff --git a/src/Binder.cpp b/src/Binder.cpp
index 409c4ef..9bca480 100644
--- a/src/Binder.cpp
+++ b/src/Binder.cpp
@@ -8,6 +8,7 @@ BindableMesh Binder::load(Mesh& mesh) {
auto vao = create_vao();
store_indices(mesh.raw_indices(), mesh.indices_size());
store_in_attribute_list(0, 3, mesh.raw(), mesh.size() * 3);
+ store_in_attribute_list(1, 2, mesh.raw_tex_coords(), mesh.tex_coords_size() * 2);
unbind_vao();
return {vao, mesh.indices_size()};
@@ -39,17 +40,20 @@ void Binder::store_in_attribute_list(uint32_t attribute, size_t size, float* dat
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, data_size * sizeof(float), data, GL_STATIC_DRAW);
- glVertexAttribPointer(attribute, size, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
+ glVertexAttribPointer(attribute, size, GL_FLOAT, GL_FALSE, size * sizeof(float), nullptr);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void BindableMesh::bind() const {
glBindVertexArray(m_vao);
glEnableVertexAttribArray(0);
+ glEnableVertexAttribArray(1);
}
void BindableMesh::unbind() {
glBindVertexArray(0);
glDisableVertexAttribArray(0);
+ glDisableVertexAttribArray(1);
}
size_t BindableMesh::size() const {
diff --git a/src/Image/PPMParser.cpp b/src/Image/PPMParser.cpp
index 0a9da54..d7d8c6a 100644
--- a/src/Image/PPMParser.cpp
+++ b/src/Image/PPMParser.cpp
@@ -8,8 +8,6 @@ namespace MC::Image {
RawImage PPMParser::parse() {
auto header = parse_header();
- std::cout << header.type << " " << header.width << " " << header.height << " " << (uint64_t)header.max_color << std::endl;
-
if (header.max_color != 255) {
throw std::logic_error("PPM max color values other than 255 are not implemented.");
}
@@ -20,7 +18,7 @@ RawImage PPMParser::parse() {
auto pixel_count = header.width * header.height;
- RawImage image(pixel_count);
+ RawImage image(pixel_count, header.width, header.height, 3);
for (uint64_t pixel_index = 0; pixel_index < pixel_count; pixel_index++) {
RawImage::Pixel pixel = parse_pixel(header.max_color);
image.add(pixel);
@@ -97,16 +95,10 @@ uint64_t PPMParser::chomp_number() {
uint8_t digit = digit_ascii - '0';
- std::cout << "digit_ascii: " << digit_ascii << std::endl;
- std::cout << "digit: " << (uint64_t)digit << std::endl;
-
number *= 10;
number += digit;
-
- std::cout << "number: " << (uint64_t)number << std::endl;
}
- std::cout << "chomp number: " << number << std::endl;
return number;
}
@@ -125,7 +117,6 @@ std::string_view PPMParser::chomp_part() {
auto part = m_source.substr(m_cursor, length);
m_cursor += length;
- std::cout << "chomped: " << part << std::endl;
return part;
}
diff --git a/src/Image/RawImage.cpp b/src/Image/RawImage.cpp
index 50478ad..00bfb0c 100644
--- a/src/Image/RawImage.cpp
+++ b/src/Image/RawImage.cpp
@@ -6,12 +6,24 @@ void RawImage::add(RawImage::Pixel pixel) {
m_pixels.push_back(pixel);
}
-size_t RawImage::size() {
+size_t RawImage::size() const {
return m_pixels.size();
}
-uint8_t* RawImage::raw() {
+uint8_t* RawImage::raw() const {
return (uint8_t*)m_pixels.data();
}
+uint32_t RawImage::width() const {
+ return m_width;
+}
+
+uint32_t RawImage::height() const {
+ return m_height;
+}
+
+uint8_t RawImage::channels() const {
+ return m_channels;
+}
+
} \ No newline at end of file
diff --git a/src/Image/RawImage.hpp b/src/Image/RawImage.hpp
index 4414ee0..6c4b122 100644
--- a/src/Image/RawImage.hpp
+++ b/src/Image/RawImage.hpp
@@ -8,9 +8,10 @@ namespace MC::Image {
class RawImage {
public:
- RawImage() : m_pixels() {};
+ RawImage() : m_pixels(), m_width(0), m_height(0), m_channels(0) {};
- explicit RawImage(size_t pixel_count) : m_pixels() {
+ explicit RawImage(size_t pixel_count, uint32_t width, uint32_t height, uint8_t channels)
+ : m_pixels(), m_width(width), m_height(height), m_channels(channels) {
m_pixels.reserve(pixel_count);
}
@@ -20,11 +21,17 @@ public:
void add(Pixel pixel);
- size_t size();
- uint8_t* raw();
+ size_t size() const;
+ uint8_t* raw() const;
+ uint32_t width() const;
+ uint32_t height() const;
+ uint8_t channels() const;
private:
std::vector<Pixel> m_pixels;
+
+ uint32_t m_width, m_height;
+ uint8_t m_channels;
};
}
diff --git a/src/Mesh.cpp b/src/Mesh.cpp
index d1f3a88..56ce9dc 100644
--- a/src/Mesh.cpp
+++ b/src/Mesh.cpp
@@ -15,3 +15,11 @@ uint32_t* MC::Mesh::raw_indices() {
size_t MC::Mesh::indices_size() {
return m_indices.size();
}
+
+float* MC::Mesh::raw_tex_coords() {
+ return (float*)m_tex_coords.data();
+}
+
+size_t MC::Mesh::tex_coords_size() {
+ return m_tex_coords.size();
+}
diff --git a/src/Mesh.hpp b/src/Mesh.hpp
index a9dadb7..50fc629 100644
--- a/src/Mesh.hpp
+++ b/src/Mesh.hpp
@@ -9,8 +9,8 @@ namespace MC {
class Mesh {
public:
- Mesh(std::vector<Vector<3>> positions, std::vector<uint32_t> indices)
- : m_positions(std::move(positions)), m_indices(std::move(indices)) {};
+ Mesh(std::vector<Vector<3>> positions, std::vector<Vector<2>> tex_coords, std::vector<uint32_t> indices)
+ : m_positions(std::move(positions)), m_tex_coords(std::move(tex_coords)), m_indices(std::move(indices)) {};
float* raw();
size_t size();
@@ -18,8 +18,12 @@ public:
uint32_t* raw_indices();
size_t indices_size();
+ float* raw_tex_coords();
+ size_t tex_coords_size();
+
private:
std::vector<Vector<3>> m_positions;
+ std::vector<Vector<2>> m_tex_coords;
std::vector<uint32_t> m_indices;
};
diff --git a/src/Texture.cpp b/src/Texture.cpp
new file mode 100644
index 0000000..d32a75a
--- /dev/null
+++ b/src/Texture.cpp
@@ -0,0 +1,27 @@
+#include <GL/glew.h>
+#include "Texture.hpp"
+
+namespace MC {
+
+Texture::Texture(const Image::RawImage& image) {
+ glGenTextures(1, &m_texture);
+ glBindTexture(GL_TEXTURE_2D, m_texture);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.raw());
+ glGenerateMipmap(GL_TEXTURE_2D);
+}
+
+void Texture::bind() {
+ glBindTexture(GL_TEXTURE_2D, m_texture);
+}
+
+void Texture::unbind() {
+ glBindTexture(GL_TEXTURE_2D, 0);
+}
+} \ No newline at end of file
diff --git a/src/Texture.hpp b/src/Texture.hpp
new file mode 100644
index 0000000..91b5e54
--- /dev/null
+++ b/src/Texture.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "Image/RawImage.hpp"
+
+namespace MC {
+
+class Texture {
+public:
+ Texture(const Image::RawImage& image);
+
+ void bind();
+ void unbind();
+private:
+ uint32_t m_texture;
+};
+
+} \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index 3da3d90..1f5d3a2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -61,7 +61,14 @@ void run() {
{0.5f, -0.5f, -0.5f},
{0.5f, 0.5f, -0.5f},
{-0.5f, 0.5f, -0.5f}
- }, {
+ },
+ {
+ {-0.5f, -0.5f}, {0.5f, 0.5f},
+ {-0.5f, 0.5f}, {0.5f, 0.5f},
+ {0.5f, -0.5f}, {0.5f, 0.5f},
+ {-0.5f, -0.5f}, {-0.5f, 0.5f}
+ },
+ {
0, 1, 2, 2, 3, 0,
1, 5, 6, 6, 2, 1,
7, 6, 5, 5, 4, 7,