Created a separate state initialisation function,

instead of Render doing it. You should call the function in any main
thread function.
Texture2D can now be used properly.