General question

View previous topic View next topic Go down

General question

Post  manuelmartinf on Wed Sep 16, 2009 2:34 am

I'm developing a first person shotter. Which do you think is the best way to implement a crosshair associated to the viewpoint?

Thank you very much!

manuelmartinf

Posts : 14
Join date : 2009-09-13

View user profile

Back to top Go down

Re: General question

Post  oioioi on Wed Sep 16, 2009 9:46 am

The way I have done this is simply go into landscape 2d(for landscape games) and then draw four lines. here is the code, just remember to go into landscape 2d(see tutorials if you don't know how to do this)
Code:
glPushMatrix();
   {
      glTranslatef( sio2->_SIO2window->scl->x * 0.5f,
                sio2->_SIO2window->scl->y * 0.5f, 0.0f );
      sio2MaterialReset();
      glColor4f(1, 1, 0, 1);
      glLineWidth(1);
      glEnableClientState(GL_VERTEX_ARRAY);
      
      float drawArray[4] = {-35, 0, -10, 0};
      glVertexPointer(2, GL_FLOAT, 0, drawArray);
      glDrawArrays(GL_LINES, 0, 2);
      
      float drawArray2[4] = {0, -35, 0, -10};
      glVertexPointer(2, GL_FLOAT, 0, drawArray2);
      glDrawArrays(GL_LINES, 0, 2);
      
      float drawArray3[4] = {35, 0, 10, 0};
      glVertexPointer(2, GL_FLOAT, 0, drawArray3);
      glDrawArrays(GL_LINES, 0, 2);
      
      float drawArray4[4] = {0, 35, 0, 10};
      glVertexPointer(2, GL_FLOAT, 0, drawArray4);
      glDrawArrays(GL_LINES, 0, 2);
   }
   glPopMatrix();
hope this helps

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: General question

Post  manuelmartinf on Thu Sep 17, 2009 5:52 am

Thank you!!!

Simple solutions are the best Smile

manuelmartinf

Posts : 14
Join date : 2009-09-13

View user profile

Back to top Go down

Re: General question

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum