2 // Linux x86_64 port of flow2, to be linked with the bold linker.
3 // Ported by Amand Tihon (alrj).
4 // Original comments in flow2 source code copied verbatim
7 // Chris Thornborrow (auld/sek/taj/copabars)
8 // If you use this code please credit...blahblah
9 // Example OGL + shaders in 1k
10 // Requires crinkler - magnificent tool
11 // VS2005 modifications by benny!weltenkonstrukteur.de from dbf
13 // NOTE: DX will beat this no problem at all due to OpenGL forced
14 // to import shader calls as variables..nontheless we dont need
15 // d3dxblahblah to be loaded on users machine.
20 // NOTE: in glsl it is legal to have a fragment shader without a vertex shader
21 // Infact ATi/AMD drivers allow this but unwisely forget to set up variables for
22 // the fragment shader - thus all GLSL programs must have a vertex shader :-(
25 // This is pretty dirty...note we do not transform the rectangle but we do use
26 // glRotatef to pass in a value we can use to animate...avoids one more getProcAddress later
30 p=sin(gl_ModelViewMatrix[1]*9.0);\
31 gl_Position=gl_Vertex;\
34 // an iterative function for colour
39 vec4 v=gl_FragCoord/400.0-1.0;\
41 for(int j=0;j<7;j++){\
44 v.y=p.g*3.0*t*v.y+v.y;\
46 gl_FragColor=vec4(mix(p,vec4(t),max(t,v.x)));\
50 static void setShaders() {
52 GLuint v = glCreateShader(GL_VERTEX_SHADER);
53 GLuint f = glCreateShader(GL_FRAGMENT_SHADER);
54 GLuint p = glCreateProgram();
56 glShaderSource(v, 1, &vsh, NULL);
59 glShaderSource(f, 1, &fsh, NULL);
69 SDL_Init(SDL_INIT_VIDEO);
70 SDL_SetVideoMode(1024, 768, 0, SDL_OPENGL);
72 SDL_ShowCursor(SDL_DISABLE);
74 //**********************
75 // NOW THE MAIN LOOP...
76 //**********************
77 // there is no depth test or clear screen...as we draw in order and cover
78 // the whole area of the screen.
81 glRotatef(0.3f, 1, 1, 1);
82 glRecti(-1, -1, 1, 1);
87 if (e.type == SDL_KEYDOWN)
89 } while (e.type != SDL_QUIT);