PDA

View Full Version : OpenGL Light!



davie
07-22-2010, 03:38 AM
Hi there,

I just want to make an interest effect: my mouse will do moving in a circle, and follow my mouse i want there
is a blue "light" moves with the circle's edge.

I saw this effect on some products. I dont know how to program the effect and whether the blue "light" is an
OPENGL light or something else(maybe it is just a picture).

Now i want to konw if this effect can be implemented with the OpenGL light? if yes, how to do the following:
1. show a blue "light" in a very small area (ie, in rect(0,0,10,10))
2. rotate the "light" around a circle's center.

I also want to know if there are any easy methods to make this?
Thanks!

ZbuffeR
07-22-2010, 12:10 PM
Sorry but I am not sure to understand what you want.

Can you show a picture or a video showing this effect ?

davie
07-22-2010, 08:23 PM
Sorry but I am not sure to understand what you want.

Can you show a picture or a video showing this effect ?

Hi ZbuffeR,

Sorry for that i dont know how to upload videos in this forum.
Thanks!

davie
07-22-2010, 09:31 PM
Sorry but I am not sure to understand what you want.

Can you show a picture or a video showing this effect ?

Hi ZbuffeR,

Here it is!
<embed src="http://us.i1.yimg.com/cosmos.bcst.yahoo.com/player/media/swf/FLVVideoSolo.swf" flashvars="id=http://video.yahoo.com/watch/7942812/21030181" type="application/x-shockwave-flash" width="425" height="350"></embed>

davie
07-23-2010, 12:21 AM
sorry it seems cannt work!

Could you give me your email? so i can email it to you.

ZbuffeR
07-23-2010, 02:37 AM
You can not upload here, but you can link an existing picture.
I will not give you an email.

davie
07-23-2010, 03:47 AM
You can not upload here, but you can link an existing picture.
I will not give you an email.

Hi ZbuffeR,

video (http://video.yahoo.com/search/?p=fxw%27s+video)

The above is the video linker!

Thanks!

ZbuffeR
07-23-2010, 04:50 AM
Well just draw a bunch of very transparent blue dots with additive blending, on the 60 or 120 last known positions of the mouse cursor.
Feel free to search for implementation details.

davie
07-23-2010, 05:35 AM
Hi ZbuffeR,

Thanks very much!

"draw a bunch of very transparent blue dots"
Sorry, i dont know how to do this.

Could i load it from a picture or do it as follow:

BYTE buf[32*32*4];
for (int i=0; i<32*32; i+=4)
{
buf[i] = 0; //R
buf[i+1] = 0; //G
buf[i+2] = 255; //B
buf[i+3] = 128; //A
}

...
...
glTexImage2D(..., ..., ..., ..., ..., ..., ..., ..., buf);

I dont know if this can work and will try later.
Are there any easy methods to do this job in OPENGL ES.
Thanks!

ZbuffeR
07-23-2010, 09:24 AM
Yeah you can draw textured quad to draw the dots.
But make sure you draw a blue circle on black background :)




BYTE buf[8*8*4] = {
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 32,128,255,16, 32,128,255,16, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 0,0,0,0, 0,0,0,0,
0,0,0,0, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 0,0,0,0,
0,0,0,0, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 0,0,0,0,
0,0,0,0, 0,0,0,0, 32,128,255,16, 32,128,255,16, 32,128,255,16, 32,128,255,16, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 32,128,255,16, 32,128,255,16, 0,0,0,0, 0,0,0,0, 0,0,0,0,
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0,
}

davie
07-24-2010, 01:26 AM
Hi ZbuffeR,

Thanks for your help!

Finally i tried to get a blue circle from a picture. Now i meet a
new problem.

My problem is:
I get a blue circle texture from a picture, but when i draw the texture, i found that it is a little different from the picture.

It looks like some ripples.(with the center is blue circle and the outer is black circle), and the blue pixels are all at the center(blue pixels bulk). I want them to be scatter. Maybe it is
because my picture is not good.

Any suggestions would be appreciated!

ZbuffeR
07-24-2010, 05:11 AM
Be sure to use :

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

And sorry about that, but the alpha coefficients must be the same for both black parts and blue parts, my array was wrong.

davie
07-25-2010, 11:11 PM
Be sure to use :

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

And sorry about that, but the alpha coefficients must be the same for both black parts and blue parts, my array was wrong.

Hi ZbuffeR,
I did the blend as the same as you, but it has no effect. Thanks very much!

ZbuffeR
07-26-2010, 05:02 AM
Screenshot ?

davie
07-26-2010, 06:07 AM
Screenshot ?

Sorry, after screenshot i found that i got a wrong picture. I got wince's screen picture and not OpenGL's picture. In my program OpenGL and GDI use different layer. OpenGL layer is beyond GDI. Thanks!