Skip to content

Commit 3d1fbd3

Browse files
changes
1 parent cc43243 commit 3d1fbd3

File tree

5 files changed

+118
-41
lines changed

5 files changed

+118
-41
lines changed

converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
text = """
2-
#version 330
2+
#version 330 core
33
layout(location=0) in vec2 aPos;
44
layout(location=1) in vec3 aCol;
55
@@ -12,14 +12,14 @@
1212
"""
1313

1414
text2 = """
15-
#version 330
15+
#version 330 core
1616
in vec3 color;
1717
1818
void main() {
1919
gl_FragColor = vec4(color.xyz, 1.0);
2020
}
2121
"""
2222

23-
for word in text:
23+
for word in text2:
2424
print(hex(ord(word)), end=", ")
2525
print(0)

dump.asm

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
.file "main.c"
2+
.intel_syntax noprefix
3+
.text
4+
.data
5+
.align 16
6+
.type beans, @object
7+
.size beans, 16
8+
beans:
9+
.long 1065353216
10+
.long 1065353216
11+
.long 1065353216
12+
.long 1065353216
13+
.text
14+
.globl bruh
15+
.type bruh, @function
16+
bruh:
17+
.LFB0:
18+
.cfi_startproc
19+
endbr64
20+
push rbp
21+
.cfi_def_cfa_offset 16
22+
.cfi_offset 6, -16
23+
mov rbp, rsp
24+
.cfi_def_cfa_register 6
25+
mov QWORD PTR -8[rbp], rdi
26+
nop
27+
pop rbp
28+
.cfi_def_cfa 7, 8
29+
ret
30+
.cfi_endproc
31+
.LFE0:
32+
.size bruh, .-bruh
33+
.globl main
34+
.type main, @function
35+
main:
36+
.LFB1:
37+
.cfi_startproc
38+
endbr64
39+
push rbp
40+
.cfi_def_cfa_offset 16
41+
.cfi_offset 6, -16
42+
mov rbp, rsp
43+
.cfi_def_cfa_register 6
44+
lea rax, beans[rip]
45+
mov rdi, rax
46+
call bruh
47+
mov eax, 0
48+
pop rbp
49+
.cfi_def_cfa 7, 8
50+
ret
51+
.cfi_endproc
52+
.LFE1:
53+
.size main, .-main
54+
.ident "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0"
55+
.section .note.GNU-stack,"",@progbits
56+
.section .note.gnu.property,"a"
57+
.align 8
58+
.long 1f - 0f
59+
.long 4f - 1f
60+
.long 5
61+
0:
62+
.string "GNU"
63+
1:
64+
.align 8
65+
.long 0xc0000002
66+
.long 3f - 2f
67+
2:
68+
.long 0x3
69+
3:
70+
.align 8
71+
4:

main

18 KB
Binary file not shown.

main.asm

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ main:
5151
; Finished with glad
5252

5353
glgarbage:
54+
mov rdi, string_format
55+
mov rsi, vsrc
56+
call printf
57+
5458
; VAO and VBO
5559
mov rdi, 1
5660
mov rsi, vao
@@ -63,12 +67,17 @@ glgarbage:
6367
call printf
6468
; VAO complete
6569

70+
mov rdi, float_format
71+
movq xmm0, [vertices + 8*(5)]
72+
mov rax, 1
73+
call printf
74+
6675
; attrb pointers
6776
mov rdi, 0
6877
mov rsi, 2
69-
mov rdx, 0x1406
78+
mov rdx, 0x140a
7079
mov rcx, 0
71-
mov r8, 60
80+
mov r8, 40
7281
mov r9, 0
7382
call [glad_glVertexAttribPointer]
7483

@@ -77,10 +86,10 @@ glgarbage:
7786

7887
mov rdi, 1
7988
mov rsi, 3
80-
mov rdx, 0x1406
89+
mov rdx, 0x140a
8190
mov rcx, 0
82-
mov r8, 60
83-
mov r9, 8
91+
mov r8, 40
92+
mov r9, 16 ; sizeof(double) * 2
8493
call [glad_glVertexAttribPointer]
8594

8695
mov rdi, 1
@@ -94,7 +103,7 @@ glgarbage:
94103
mov rsi, [vbo]
95104
call [glad_glBindBuffer]
96105
mov rdi, 34962
97-
mov rsi, 60
106+
mov rsi, 120
98107
mov rdx, vertices
99108
mov rcx, 0x8892
100109
call [glad_glBufferData]
@@ -121,8 +130,16 @@ glgarbage:
121130
call [glad_glShaderSource]
122131
mov rdi, [fshader]
123132
call [glad_glCompileShader]
124-
; ------------------------- Shaders DONE ---------------------------------;
125133

134+
mov rdi, int_format
135+
mov rsi, [vshader]
136+
call printf
137+
138+
mov rdi, int_format
139+
mov rsi, [fshader]
140+
call printf
141+
142+
; ------------------------- Shaders DONE ---------------------------------;
126143

127144

128145
; ------------------------- Shader program ------------------------------;
@@ -140,7 +157,10 @@ glgarbage:
140157
call [glad_glUseProgram]
141158
; ------------------------- Shader program DONE ---------------------------;
142159

143-
160+
mov rdi, int_format
161+
mov rsi, [program]
162+
call printf
163+
144164
loop:
145165
movd xmm0, [zero]
146166
movd xmm1, [r]
@@ -151,6 +171,12 @@ loop:
151171
mov rdi, 16384
152172
call [glad_glClear]
153173
174+
mov rdi, [vao]
175+
call [glad_glBindVertexArray]
176+
177+
mov rdi, [program]
178+
call [glad_glUseProgram]
179+
154180
mov rdi, 0x0004
155181
mov rsi, 0
156182
mov rdx, 3
@@ -186,33 +212,18 @@ section .rodata
186212
int_format: db "%d", 10, 0
187213
float_format: db "%f", 10, 0
188214
pointer_format: db "%p", 10, 0
215+
string_format: db "%s", 10, 0
189216
title: db "Hello, world!", 0
190217
error: db "Failed to load gl functions!", 10
191218
len equ $ - error
192219
r: dd 0.2
193220
test: dq 0.2
194221
zero: dd 0.0
195-
vertices:
196-
dq -0.5
197-
dq -0.5
198-
dq 1.0 ; red
199-
dq 0.0 ; green
200-
dq 0.0 ; blue
201-
dq 0.0
202-
dq 0.37
203-
dq 0.0 ; red
204-
dq 1.0 ; gree
205-
dq 0.0 ; blue
206-
dq 0.5
207-
dq -0.5
208-
dq 0.0 ; red
209-
dq 0.0 ; green
210-
dq 1.0 ; blue
222+
vertices: dq -0.5, -0.5, 1.0, 0.0, 0.0, 0.0, 0.37, 0.0, 1.0, 0.0, 0.5, -0.5, 0.0, 0.0, 1.0
211223
vsrc:
212-
db 0xa, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30, 0xa, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x30, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x50, 0x6f, 0x73, 0x3b, 0xa, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x31, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x43, 0x6f, 0x6c, 0x3b, 0xa, 0xa, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0xa, 0xa, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x61, 0x50, 0x6f, 0x73, 0x2e, 0x78, 0x79, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x20, 0xa, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x61, 0x43, 0x6f, 0x6c, 0x3b, 0xa, 0x7d, 0xa, 0
224+
db 0xa, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30, 0x20, 0x63, 0x6f, 0x72, 0x65, 0xa, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x30, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x50, 0x6f, 0x73, 0x3b, 0xa, 0x6c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x28, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x31, 0x29, 0x20, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x43, 0x6f, 0x6c, 0x3b, 0xa, 0xa, 0x6f, 0x75, 0x74, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0xa, 0xa, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x61, 0x50, 0x6f, 0x73, 0x2e, 0x78, 0x79, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0x20, 0xa, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x61, 0x43, 0x6f, 0x6c, 0x3b, 0xa, 0x7d, 0xa, 0
213225
fsrc:
214-
db 0xa, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30, 0xa, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0xa, 0xa, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x78, 0x79, 0x7a, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0xa, 0x7d, 0xa, 0
215-
226+
db 0xa, 0x23, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x33, 0x33, 0x30, 0x20, 0x63, 0x6f, 0x72, 0x65, 0xa, 0x69, 0x6e, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0xa, 0xa, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x28, 0x29, 0x20, 0x7b, 0xa, 0x20, 0x20, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x78, 0x79, 0x7a, 0x2c, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x3b, 0xa, 0x7d, 0xa, 0
216227
pvsrc:
217228
dq vsrc
218229
pfsrc:

main.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
#include <stddef.h>
22
#include <stdio.h>
33

4+
#include <glad/glad.h>
45
#include <GLFW/glfw3.h>
56

6-
int main(void) {
7-
// glfwInit();
8-
9-
// GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
10-
// printf("%ld\n", sizeof(window));
7+
static float beans[4] = {1.0, 1.0, 1.0, 1.0};
118

12-
// glfwTerminate();
13-
printf("%ld\n", sizeof(float));
14-
printf("%ld\n", sizeof(double));
9+
int bruh(float *yes) {
1510

16-
double d = 0.12309489873923849;
17-
printf("%.100lf\n", d);
18-
printf("%.100f\n", d);
11+
}
1912

13+
int main(void) {
14+
bruh(beans);
2015
return 0;
2116
}

0 commit comments

Comments
 (0)