Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with loops #11

Closed
yesimwearingpants opened this issue May 2, 2015 · 1 comment
Closed

Problem with loops #11

yesimwearingpants opened this issue May 2, 2015 · 1 comment

Comments

@yesimwearingpants
Copy link

I am trying to alternate colors so I used this loop
float j;
do {
if(j==.8){
//b for blue
b = uv.y+j;
j -= .1;
} else if ( j== .4){
b = uv.y+j;
j -= .1;
} j=.4;
} while (j!=1.0);

It freezes and crashes on compile. I wanted to use
ctime for a delay but is there a better way I
should be doing this, I an Very new too OpenGL

@markusfisch
Copy link
Owner

I'm sorry, I don't quite understand what you're trying to do. If you're simply trying to alternate colors, it's better to use math instead of conditional statements.

Something like:

gl_FragColor = vec4(
    sin( time*0.2 ),
    sin( time*0.3 ),
    sin( time*0.4 ),
    1.0 );

Please have a look at the GLSL documentation and check out a few simple shaders from here or here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants