Demivec wrote:@Mijikai: Wouldn't you want to use CompilerIf/CompilerEndIf instead of If/EndIf in Macro i()?
Thanks
Yes, i added the macro right in the post box as it was missing and made a mistake
Here are more Macros:
Code: Select all
Macro sa(a);< ascii string + #CRLF$
!db a#,0x0D,0x0A
EndMacro
Macro su(a);< unicode string + #CRLF$
!du a#,0x0D,0x0A
EndMacro
;Note: replace the old EndSection() with this (adds a null terminator for strings)
Macro EndSection()
!dw 0h
!@@:
EndMacro
Snipped where i use the Macros
Code: Select all
;...
Section(vertices)
f() 1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0
f() -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0
f() -1.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0
f() 1.0, -1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0
f() 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0
f() -1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0
EndSection()
*vbo = render_CreateVertexBuffer(?vertices,48 * 4,#GL_STATIC_DRAW)
*vao = render_CreateVertexArray()
*vao\Layout(3,#GL_FLOAT,#GL_FALSE)
*vao\Layout(3,#GL_FLOAT,#GL_FALSE)
*vao\Layout(2,#GL_FLOAT,#GL_FALSE)
*vao\Buffer(*vbo)
Section(vertex_shader)
sa("#version 330 core")
sa("layout (location = 0) in vec3 aPos;")
sa("layout(location = 1) in vec3 aColor;")
sa("layout(location = 2) in vec2 aUV;")
sa("out vec3 vertexColor;")
sa("out vec2 vertexUV;")
sa("void main()")
sa("{")
sa(" vertexColor = aColor;")
sa(" vertexUV = aUV;")
sa(" gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);")
sa("}")
EndSection()
Section(fragment_shader)
sa("#version 330 core")
sa("out vec4 FragColor;")
sa("in vec3 vertexColor;")
sa("in vec2 vertexUV;")
sa("uniform sampler2D myTexture;")
sa("void main()")
sa("{")
sa(" vec2 ndc = vertexUV * 2.0 - 1.0;")
sa(" //vec3 color = vertexColor * length(ndc);")
sa(" vec3 color = texture(myTexture, vertexUV).rgb;")
sa(" FragColor = vec4(color.rgb, 1.0f);")
sa("}")
EndSection()
*sdr = render_NewShader()
*sdr\Add(?vertex_shader,#Null$,#GL_VERTEX_SHADER)
*sdr\Add(?fragment_shader,#Null$,#GL_FRAGMENT_SHADER)
*sdr\Link()
;...
Just suit the macros to your need and enjoy
Note:
Sadly stacking different data-types horizontally is currently still not possible.