Problem when shooting

Hi. I’m trying to create a platform that shots from the base of the screen. The base itself shots a line, but when I move the platform, the bullet moves with it. I think its something about the transformation matrix.
here is the code that i use

void display(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glRectf(-48.0,-38.0,-28.0,-35.0);
glRectf(28.0,-38.0,48.0,-35.0);

    glPushMatrix();
    glTranslatef(x,0.0,1.0); 	
    glColor3f(0.2,0.3,0.8);
    glBegin(GL_TRIANGLE_FAN);
	glVertex2f(-8.0, -48.0);
	glVertex2f(8.0, -48.0);
	glVertex2f(0.0, -40.0);
glEnd();
glPopMatrix();
	
glPushMatrix();
    glTranslatef(x1,y,1.0); 	
glColor3f(1.0,0.5,0.0);
glRectf(-0.1,-41.0,0.1,-40.0);   
glPopMatrix();


glutSwapBuffers();	

}

thanks

Since I don’t know the rest of your code I may be wrong, but from what I see a simple
glLoadIdentity();
right after your glClear should do it.

it sounds to me like your problem is more fundamental than an opengl issue. do you have a different x variable for your bullet, or are you just drawing it to the base x? this is a common problem for beginners because the pseudo-code sounds almost like it should work.

man, I am not using different variables for the bullet and the base. How I do that?

Thanks

Well, look. I use a variable for the coordinate x of the bullent and other for the coordinate of the base. But my real problem is: the movement of the bullet when is shot is controlled by the idleFunc, but when i press a key to move the base, the bullet stops (because the key press is an event). How do I correct this?. A guy told me that I must put a call to the idle on the key press, but I dont think that is a good way.

Thanks for the help.

You could do as “the guy” tells you, but by that your bullet will be slower or faster depending on your key-press behaviour.
So a (very) simple approach would be to put your rendering code and the coordinate modification of the bullet into a timer triggered function.

You want to initialize OpenGL?

DC := GetDC(Handle);
RC := CreateRenderingContext(DC, [opDoubleBuffered, 32, 24, 16, 0,0,0, InitPal);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

try this… That perfect rendering.

Naphadol Mekiyanon [Dol]

:eek:
glEnable(GL_POLYGON_SMOOTH);
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);

You should never need this in standard OpenGL applications. It doesn’t work well/at all with depth test and if you don’t have saturate blending enabled and sort polygons from front to back, this will not have any beneficial effect.

Some hardware just ignores it, the newer which doesn’t will slow down and show artifacts.

If you don’t know what you’re doing, don’t use GL_POLYGON_SMOOTH.

Bone01.x1[MTXSource, MTXTarget] := Sqrt((x1x2)/(x1+x2))-Sqrt((x1x1/x2)+(x2x2/x1));
Bone01.y1[MTXSource, MTXTarget] := Sqrt((y1+(x1-z1)
(x2-z2)/((x2y1)+(z2y1))/(y2-y1));
Bone01.z1[MTXSource, MTXTarget] := Sqrt((z2Sin(z1+z2))-(z1(Cos(z1+z2)/(x2*x1)));

Woaw the central bone is great effectively movement to target.

If you want to other bone in human model that have 26 bones system.

I have controller bone module calculation more this…

E-mail to me : dol_3ddev@.hotmail.com

If don’t connect to video card that is slower.

Do you use glGetString(GL_RENDERER); ?

wglGetProcAddress(glGetString(GL_RENDERER));
I use in OpenGL 1.5 (dglOpenGL.dll).

Can it be that you’re a little confused?
You opened a new thread answering to this thread and wglGetProcAddress(glGetString(GL_RENDERER)) doesn’t make the least sense.