Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Port of flow2 to be compiled and linked by dnload.py, platform-independent.
- // Both original comments and those from Amand Tihon copied verbatim.
- // Linux x86_64 port of flow2, to be linked with the bold linker.
- // Ported by Amand Tihon (alrj).
- // Original comments in flow2 source code copied verbatim
- // Chris Thornborrow (auld/sek/taj/copabars)
- // If you use this code please credit...blahblah
- // Example OGL + shaders in 1k
- // Requires crinkler - magnificent tool
- // VS2005 modifications by benny!weltenkonstrukteur.de from dbf
- // Greets!
- // NOTE: DX will beat this no problem at all due to OpenGL forced
- // to import shader calls as variables..nontheless we dont need
- // d3dxblahblah to be loaded on users machine.
- #include "dnload.h"
- // NOTE: in glsl it is legal to have a fragment shader without a vertex shader
- // Infact ATi/AMD drivers allow this but unwisely forget to set up variables for
- // the fragment shader - thus all GLSL programs must have a vertex shader :-(
- // Thanks ATI/AMD
- // This is pretty dirty...note we do not transform the rectangle but we do use
- // glRotatef to pass in a value we can use to animate...avoids one more getProcAddress later
- const GLchar *vsh="\
- varying vec4 p;\
- void main(){\
- p=sin(gl_ModelViewMatrix[1]*9.0);\
- gl_Position=gl_Vertex;\
- }";
- // an iterative function for colour
- const GLchar *fsh="\
- varying vec4 p;\
- void main(){\
- float r,t,j;\
- vec4 v=gl_FragCoord/400.0-1.0;\
- r=v.x*p.r;\
- for(int j=0;j<7;j++){\
- t=v.x+p.r*p.g;\
- v.x=t*t-v.y*v.y+r;\
- v.y=p.g*3.0*t*v.y+v.y;\
- }\
- gl_FragColor=vec4(mix(p,vec4(t),max(t,v.x)));\
- }";
- //p.g*3.0*t*v.y+i;\
- static void setShaders() {
- GLuint v = dnload_glCreateShader(GL_VERTEX_SHADER);
- GLuint f = dnload_glCreateShader(GL_FRAGMENT_SHADER);
- GLuint p = dnload_glCreateProgram();
- dnload_glShaderSource(v, 1, &vsh, NULL);
- dnload_glCompileShader(v);
- dnload_glAttachShader(p, v);
- dnload_glShaderSource(f, 1, &fsh, NULL);
- dnload_glCompileShader(f);
- dnload_glAttachShader(p, f);
- dnload_glLinkProgram(p);
- dnload_glUseProgram(p);
- }
- void _start()
- {
- static SDL_Event e;
- dnload();
- dnload_SDL_Init(SDL_INIT_VIDEO);
- dnload_SDL_SetVideoMode(1024, 768, 0, SDL_OPENGL);
- dnload_SDL_ShowCursor(SDL_DISABLE);
- setShaders();
- //**********************
- // NOW THE MAIN LOOP...
- //**********************
- // there is no depth test or clear screen...as we draw in order and cover
- // the whole area of the screen.
- do
- {
- dnload_glRotatef(0.3f, 1, 1, 1);
- dnload_glRecti(-1, -1, 1, 1);
- dnload_SDL_GL_SwapBuffers();
- dnload_SDL_PollEvent(&e);
- if (e.type == SDL_KEYDOWN)
- break;
- } while (e.type != SDL_QUIT);
- asm_exit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement