Exemplo n.º 1
0
void desenha_legendas()
{

  glDisable(GL_TEXTURE_2D);

  glMatrixMode(GL_MODELVIEW);

  glPushMatrix();
  glLoadIdentity();

  glTranslatef(2.5, -2.8, 0.0);

  glColor3f(0.68, 0.9, 0.59);
  glRasterPos3f(2.7, -4.8, -10);
  
  string timestep_msg;
  if (cur_iter == SIMULATION_NOT_STARTED)
    timestep_msg = "Simulation not started";
  else if (cur_iter == SIMULATION_OVER)
    timestep_msg = "Simulation OVER (" + intToString(iterations) + ")";
  else
    timestep_msg = "timestep: " + intToString(cur_iter);
  
  glPrint((char *)timestep_msg.c_str());
  
  glRasterPos3f(-10.5, 10.0, -10);
  string network_msg = "Network: " + string(network_name);
  glPrint((char *)network_msg.c_str()); 

  glPopMatrix();

}
Exemplo n.º 2
0
GLvoid NEHE17::DrawGLScene(){
	
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	glLoadIdentity();
	glBindTexture(GL_TEXTURE_2D, texture[1]);
	glTranslatef(0.0f,0.0f,-5.0f);
	glRotatef(45.0f,0.0f,0.0f,1.0f);
	glRotatef(cnt1*30.0f,1.0f,1.0f,0.0f);
	glDisable(GL_BLEND);
	glColor3f(1.0f,1.0f,1.0f);
	glBegin(GL_QUADS);
	glTexCoord2d(0.0f,0.0f);
	glVertex2f(-1.0f, 1.0f);
	glTexCoord2d(1.0f,0.0f);
	glVertex2f( 1.0f, 1.0f);
	glTexCoord2d(1.0f,1.0f);
	glVertex2f( 1.0f,-1.0f);
	glTexCoord2d(0.0f,1.0f);
	glVertex2f(-1.0f,-1.0f);
	glEnd();
	glRotatef(90.0f,1.0f,1.0f,0.0f);
	glBegin(GL_QUADS);
	glTexCoord2d(0.0f,0.0f);
	glVertex2f(-1.0f, 1.0f);
	glTexCoord2d(1.0f,0.0f);
	glVertex2f( 1.0f, 1.0f);
	glTexCoord2d(1.0f,1.0f);
	glVertex2f( 1.0f,-1.0f);
	glTexCoord2d(0.0f,1.0f);
	glVertex2f(-1.0f,-1.0f);
	glEnd();
	glEnable(GL_BLEND);
	
	glLoadIdentity();
	glColor3f(1.0f*float(cos(cnt1)),1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)));
	glPrint(int((280+250*cos(cnt1))),int(235+200*sin(cnt2)),"NeHe",0);
	
	glColor3f(1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)),1.0f*float(cos(cnt1)));
	glPrint(int((280+230*cos(cnt2))),int(235+200*sin(cnt1)),"OpenGL",1);
	
	glColor3f(0.0f,0.0f,1.0f);
	glPrint(int(240+200*cos((cnt2+cnt1)/5)),2,"Andong Li",0);
	glColor3f(1.0f,1.0f,1.0f);
	glPrint(int(242+200*cos((cnt2+cnt1)/5)),2,"Andong Li",0);
		
	//draw FPS text
	glDisable(GL_TEXTURE_2D);
	glLoadIdentity ();
	glTranslatef(0.0f,0.0f,-1.0f);
	glColor3f(0.8f,0.8f,0.8f);//set text color
	computeFPS();
	Utils::drawText(-0.54f,-0.4f, GLUT_BITMAP_HELVETICA_12, FPSstr);
	glEnable(GL_TEXTURE_2D);
		
	glutSwapBuffers();
	
	cnt1 += 0.01f;
	cnt2 += 0.0081f;
}
Exemplo n.º 3
0
static void display(void){
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	
	if(csg_mode)renderInCSGMode();
	else renderShape();
	
	char string[20];
	glLoadIdentity();
	sprintf(string,"FPS: %02.0f",fps);
	glPrint(string,5,15);
	if(crystal > 0.0){
		sprintf(string,"C: %.2f%%",crystal);
		glPrint(string,5,30);
	}
	if(animation){
		sprintf(string,"Frame: %03d",ani_frame);
		if(crystal > 0.0) glPrint(string,5,45);
		else glPrint(string,5,30);
	}
	
	if(renderdiff){
		renderDiffraction();
	}
	glutSwapBuffers();
}
Exemplo n.º 4
0
//-*****************************************************************************
void overlay()
{
    if ( !g_state.showHelp )
    {
        return;
    }

    glDisable( GL_LIGHTING );
    glDisable( GL_DEPTH_TEST );

    glColor4f( .1f, .9f, .1f, 1.0f );
    glPrint( -5, 5, "Good" );

    glColor4f( .9f, .1f, .1f, 1.0f );
    glPrint( -5, 4.5, "Inverse Normals" );

    glColor4f( .1f, .1f, .9f, 1.0f );
    glPrint( -5, 4, "Negative Transform" );

    glColor4f( .9f, .1f, .9f, 1.0f );
    glPrint( -5, 3.5, "Negative Transform + Inverse Normals" );

    glEnable( GL_LIGHTING );
    glEnable( GL_DEPTH_TEST );
}
Exemplo n.º 5
0
/* Draw all texts on screen */
GLvoid DrawText()
{
	glPushAttrib(GL_CURRENT_BIT);
	glLoadIdentity();									// Reset the current model-view matrix
	glTranslatef(0.0f, 0.0f, -1.0f);					// Move 1 unit into screen
	// Pulsing colors based on text position
	glColor3fv(s_WhiteColor);
	//glColor3fv(s_BlueColor);
	//glColor3f(1.0f * float(cos(g_fTextPosX)),
	//	1.0f * float(sin(g_fTextPosY)),
	//	1.0f - 0.5f * float(cos(g_fTextPosX + g_fTextPosY)));
	// Position the text on screen
	float fX = -0.45f + 0.05f * float(cos(g_fTextPosX));
	float fY = 0.35f * float(sin(g_fTextPosY));
	//glRasterPos2f(-0.45f + 0.05f * float(cos(g_fTextPosX)),
	//	0.35f * float(sin(g_fTextPosY)));
	glRasterPos2f(g_fTextPosX, g_fTextPosY);
	glPrint("%20s - %17.2X", "hDC", hDC);
	g_fTextPosY -= g_fLineSpace;
	glRasterPos2f(g_fTextPosX, g_fTextPosY);
	glPrint("%20s - %17.2X", "hWnd", hWnd);
	/*g_fTextPosY -= g_fLineSpace;
	glRasterPos2f(g_fTextPosX, g_fTextPosY);
	glPrint("% 20s - %17.2X", "hInstance", hInstance);
	g_fTextPosY -= g_fLineSpace;
	glRasterPos2f(g_fTextPosX, g_fTextPosY);
	glPrint("% 20s - %17.2X", "g_bActive", g_bActive);
	g_fTextPosY -= g_fLineSpace;
	glRasterPos2f(g_fTextPosX, g_fTextPosY);
	glPrint("% 20s - %17.2X", "g_bFullscreen", g_bFullscreen);*/


	glColor3fv(s_WhiteColor);
}
Exemplo n.º 6
0
void draw_screen( void ) {
    // Step
    you_angle += ( 10 * you_velocity * you_turn ) / fps;
    
    float you_x_new = you_x - ( (float)sin(you_angle*piover180) * you_velocity * you_dir ) / fps;
    float you_z_new = you_z + ( (float)cos(you_angle*piover180) * you_velocity * you_dir ) / fps;
    int joel = boundCheck(you_x_new, you_x_new, you_z_new, you_z_new); // TODO change this to avoid repetition
    if (joel == 1) {
        you_x = you_x_new;
        you_z = you_z_new;
    }
    
    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen and The Depth Buffer
    /* We don't want to modify the projection matrix. */
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity(); you_compensate();
    
    // Some nice material/colour settings
    glColorMaterial ( GL_FRONT_AND_BACK, GL_EMISSION ) ;
    glEnable ( GL_COLOR_MATERIAL ) ;
    
    glLoadIdentity(); you_compensate();
    glTranslatef( 0.0f, 3.0f, 0.0f );
    draw_cube();
    
    DrawWorld();
    
    if (debug) {
        glLoadIdentity(); glTranslatef(0, 0, -1);
        glColor3f(1, 1, 1);
        glRasterPos2f(-0.7f, -0.5f);
        glPrint("X: %f   Z: %f   Angle: %f   Velocity: %f", you_x, you_z, you_angle, you_velocity);
        glRasterPos2f(-0.7f, 0.5f);
        glPrint("FPS: %f", fps);
    }
    
    if (joel == 12) {
        glLoadIdentity(); glTranslatef(0, 0, -1);
        glColor3f(1, 1, 1);
        glRasterPos2f(-0.7f, 0.5f);
        glPrint("The Cake,");
        glRasterPos2f(-0.7f, 0.4f);
        glPrint("Is a Lie!!");
//         glRasterPos2f(-0.7f, 0.3f);
//         glPrint("Third Line");
    }
    
    Frames++;
    GLint t = SDL_GetTicks();
    if (t - T0 >= 100) {
        GLfloat seconds = (t - T0) / 1000.0;
        fps = Frames / seconds;
        T0 = t;
        Frames = 0;
    }
    
    SDL_GL_SwapBuffers( );
}
Exemplo n.º 7
0
void PrintDebugMessage() {
	glBindTexture(GL_TEXTURE_2D, 0);

	float3 pos = m_Player->eyepos;

	int3 id((int)floor(pos.x / (BLOCK_LEN*CHUNK_W)), 
		(int)floor(pos.y / (BLOCK_LEN*CHUNK_L)), 
		(int)floor(pos.z / (BLOCK_LEN*CHUNK_H)));
#ifndef APPLE
	millis = tickFreq/(currTick.LowPart - lastTick.LowPart);
#endif
	char buffer[128];

	glPushMatrix();

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glOrtho(0, _width, 0, _height, -1, 1);

	glScalef(20, 20, 1);
	
	glPushMatrix();
	glPrint("Ms:%4.0f %d,%d,%d", millis, id.x, id.y, id.z);
	glPopMatrix();
	
	s_Render->PrintChunkStatistics(buffer);
	glPushMatrix();
	glTranslatef(0, 1, 0);
	glPrint("%s", buffer);
	glPopMatrix();

	glPopMatrix();
}
Exemplo n.º 8
0
void glPrintShadowed(int x, int y, const char *s, void *font, float *color)
{
    glColor3f(0.0, 0.0, 0.0);
    glPrint(x-1, y-1, s, font);

    glColor3fv((GLfloat *) color);
    glPrint(x, y, s, font);
}
Exemplo n.º 9
0
/* Function to print the string */
GLvoid glPrintStereo( GLint w, GLint h, GLint x, GLint y, char *string, int set )
{

  //printf("w %d, h %d, x %d, y %d\n",w, h, x,y);
  glPrint(w, h, x, y, string, set );
  glPrint(w, h, (x+w/2), y, string, set );

}
Exemplo n.º 10
0
GLvoid glPrint2(GLdouble x, GLdouble y, GLdouble z, GLubyte r, GLubyte g, GLubyte b, const char *string, ...)		// Where The Printing Happens
{

//////////////////////////////////
  GLint    viewport[4];    // параметры viewport-a.
  GLdouble projection[16]; // матрица проекции.
  GLdouble modelview[16];  // видовая матрица.
  //GLdouble vx,vy,vz;       // мировые координаты.
  GLdouble wx,wy,wz;       // возвращаемые координаты в системе координат viewport-a.

  //glScalef(scale,scale,scale);

  glGetIntegerv(GL_VIEWPORT,viewport);           // узнаём параметры viewport-a.
  glGetDoublev(GL_PROJECTION_MATRIX,projection); // узнаём матрицу проекции.
  glGetDoublev(GL_MODELVIEW_MATRIX,modelview);   // узнаём видовую матрицу.
  // переводим оконные координаты курсора в систему координат viewport-a.
//  vx = mouse_x;
//  vy = window_height - mouse_y - 1; // где height - текущая высота окна.
  // вычисляем ближний конец селектирующего отрезка.
//  vz = -1;
  gluProject(x, y, z, modelview, projection, viewport, &wx, &wy, &wz);

  glColor3ub(0, 0, 0);
  glPrint((int)wx+1,window_height-(int)wy  ,string);
  glPrint((int)wx-1,window_height-(int)wy  ,string);
  glPrint((int)wx  ,window_height-(int)wy+1,string);
  glPrint((int)wx  ,window_height-(int)wy-1,string);

  glColor3ub(r, g, b);
  glPrint((int)wx,window_height-(int)wy,string);

///////////////////////////////////
/*	char		text[256];										// Holds Our String
	va_list		ap;												// Pointer To List Of Arguments

	if (string == NULL)											// If There's No Text
		return;													// Do Nothing

	va_start(ap, string);										// Parses The String For Variables
	    vsprintf(text, string, ap);								// And Converts Symbols To Actual Numbers
	va_end(ap);													// Results Are Stored In Text

	glPushAttrib(GL_LIST_BIT);	// Position The Text (0,0 - Bottom Left)
	glPushMatrix();												// Store The Modelview Matrix
	glLoadIdentity();											// Reset The Modelview Matrix
	//glTranslated(x,y,z);
	glTranslatef(wx,window_height-wy,-1.f);
	glListBase(base-32);
	glDisable(GL_LIGHTING);
	glRasterPos2f(0.03*scale,0.03*scale);// Choose The Font Set
	glCallLists(strlen(text), GL_UNSIGNED_BYTE, text);			// Draws The Display List Text
	glEnable(GL_LIGHTING);
	glPopMatrix();	
	glPopAttrib();// Restore The Old Projection Matrix
*/
}
Exemplo n.º 11
0
void ParamListGL::Render(int x, int y, bool shadow)
{
    beginWinCoords();
    start_x = x; start_y = y;

    for(std::vector<ParamBase *>::const_iterator p = m_params.begin(); p != m_params.end(); ++p)
    {
        if ((*p)->IsList())
        {
            ParamListGL *list = (ParamListGL *) (*p);
            list->Render(x+10, y);
            y += separation*list->GetSize();
        } 
        else 
        {
            if (p == m_current)
            {
                glColor3fv(text_col_selected);
            }
            else
            {
                glColor3fv(text_col_unselected);
            }

            if (shadow)
            {
                glPrintShadowed(x + text_x, y + font_h, (*p)->GetName()->c_str(), font, (p == m_current) ? text_col_selected : text_col_unselected);
                glPrintShadowed(x + value_x, y + font_h, (*p)->GetValueString().c_str(), font, (p == m_current) ? text_col_selected : text_col_unselected);
            }
            else 
            {
                glPrint(x + text_x, y + font_h, (*p)->GetName()->c_str(), font);
                glPrint(x + value_x, y + font_h, (*p)->GetValueString().c_str(), font);
            } 

            // glColor3fv((GLfloat *) &bar_col_outer);
            glBegin(GL_LINE_LOOP);
            glVertex2f((GLfloat)(x + bar_x)        , (GLfloat)(y + bar_offset));
            glVertex2f((GLfloat)(x + bar_x + bar_w), (GLfloat)(y + bar_offset));
            glVertex2f((GLfloat)(x + bar_x + bar_w), (GLfloat)(y + bar_offset + bar_h));
            glVertex2f((GLfloat)(x + bar_x)        , (GLfloat)(y + bar_offset + bar_h));
            glEnd();

            // glColor3fv((GLfloat *) &bar_col_inner);
            glRectf((GLfloat)(x + bar_x), (GLfloat)(y + bar_offset + bar_h), (GLfloat)(x + bar_x + (bar_w*(*p)->GetPercentage())), (GLfloat)(y + bar_offset));
            y += separation;
        }
    }

    endWinCoords();
}
Exemplo n.º 12
0
int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
{
#if 1
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
//  glOrtho(-0.5, (windowWidth - 1) + 0.5, (windowHeight - 1) + 0.5, -0.5, -1.0, 1.0);
  glOrtho(-0.5, (640 - 1) + 0.5, (480 - 1) + 0.5, -0.5, -1.0, 1.0);

  glBegin(GL_LINES);
  glVertex2f(0, 200.0f);
  glVertex2f(200.0f, 0);
  glEnd();
#else
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer
	glLoadIdentity();									// Reset The Current Modelview Matrix
	glTranslatef(0.0f,0.0f,-1.0f);						// Move One Unit Into The Screen
#endif

  // Pulsing Colors Based On Text Position
	glColor3f(1.0f*float(cos(cnt1)),1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)));
	// Position The Text On The Screen
  float candidateX = -0.45f+0.3f*float(cos(cnt1));
//	glRasterPos2f(candidateX > 0.0f?candidateX:0.0f, 0.3f*float(sin(cnt2)));
	glRasterPos2f(100, 100);
 	glPrint("Active OpenGL Text With NeHe - %7.2f", cnt1);	// Print GL Text To The Screen
	glRasterPos2f(200, 200);
 	glPrint("Hi");	// Print GL Text To The Screen
#if 1
  glBegin(GL_LINES);
  float centerX = 320;
  float centerY = 240;
  float scale = 50.0f;//0.1f;
  for ( int i = 1; i < 10;  i++ )
  {
    float size = i * scale;
    glVertex2f(centerX-size, centerY-size);
    glVertex2f(centerX-size, centerY+size);
    glVertex2f(centerX+-size, centerY+size);
    glVertex2f(centerX+size, centerY+size);
    glVertex2f(centerX+size, centerY+size);
    glVertex2f(centerX+size, centerY-size);
    glVertex2f(centerX+size, centerY-size);
    glVertex2f(centerX-size, centerY-size);
  }
  glEnd();
#endif
	cnt1+=0.001f;										// Increase The First Counter
	cnt2+=0.001f;										// Increase The First Counter
	return TRUE;										// Everything Went OK
}
Exemplo n.º 13
0
int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
	glLoadIdentity();									// Reset The Modelview Matrix
	glBindTexture(GL_TEXTURE_2D, texture[1]);			// Select Our Second Texture
	glTranslatef(0.0f,0.0f,-5.0f);						// Move Into The Screen 5 Units
	glRotatef(45.0f,0.0f,0.0f,1.0f);					// Rotate On The Z Axis 45 Degrees (Clockwise)
	glRotatef(cnt1*30.0f,1.0f,1.0f,0.0f);				// Rotate On The X & Y Axis By cnt1 (Left To Right)
	glDisable(GL_BLEND);								// Disable Blending Before We Draw In 3D
	glColor3f(1.0f,1.0f,1.0f);							// Bright White
	glBegin(GL_QUADS);									// Draw Our First Texture Mapped Quad
		glTexCoord2d(0.0f,0.0f);						// First Texture Coord
		glVertex2f(-1.0f, 1.0f);						// First Vertex
		glTexCoord2d(1.0f,0.0f);						// Second Texture Coord
		glVertex2f( 1.0f, 1.0f);						// Second Vertex
		glTexCoord2d(1.0f,1.0f);						// Third Texture Coord
		glVertex2f( 1.0f,-1.0f);						// Third Vertex
		glTexCoord2d(0.0f,1.0f);						// Fourth Texture Coord
		glVertex2f(-1.0f,-1.0f);						// Fourth Vertex
	glEnd();											// Done Drawing The First Quad
	glRotatef(90.0f,1.0f,1.0f,0.0f);					// Rotate On The X & Y Axis By 90 Degrees (Left To Right)
	glBegin(GL_QUADS);									// Draw Our Second Texture Mapped Quad
		glTexCoord2d(0.0f,0.0f);						// First Texture Coord
		glVertex2f(-1.0f, 1.0f);						// First Vertex
		glTexCoord2d(1.0f,0.0f);						// Second Texture Coord
		glVertex2f( 1.0f, 1.0f);						// Second Vertex
		glTexCoord2d(1.0f,1.0f);						// Third Texture Coord
		glVertex2f( 1.0f,-1.0f);						// Third Vertex
		glTexCoord2d(0.0f,1.0f);						// Fourth Texture Coord
		glVertex2f(-1.0f,-1.0f);						// Fourth Vertex
	glEnd();											// Done Drawing Our Second Quad
	glEnable(GL_BLEND);									// Enable Blending

	glLoadIdentity();									// Reset The View
	// Pulsing Colors Based On Text Position
	glColor3f(1.0f*float(cos(cnt1)),1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)));
	glPrint(int((280+250*cos(cnt1))),int(235+200*sin(cnt2)),"NeHe",0);		// Print GL Text To The Screen

	glColor3f(1.0f*float(sin(cnt2)),1.0f-0.5f*float(cos(cnt1+cnt2)),1.0f*float(cos(cnt1)));
	glPrint(int((280+230*cos(cnt2))),int(235+200*sin(cnt1)),"OpenGL",1);	// Print GL Text To The Screen

	glColor3f(0.0f,0.0f,1.0f);							// Set Color To Blue
	glPrint(int(240+200*cos((cnt2+cnt1)/5)),2,"Giuseppe D'Agata",0);

	glColor3f(1.0f,1.0f,1.0f);							// Set Color To White
	glPrint(int(242+200*cos((cnt2+cnt1)/5)),2,"Giuseppe D'Agata",0);

	cnt1+=0.01f;										// Increase The First Counter
	cnt2+=0.0081f;										// Increase The Second Counter
	return TRUE;										// Everything Went OK
}
Exemplo n.º 14
0
    void cWindowTextShower::ShowMatrix(const cMatrixf& aMatrix)
    {
        glNormal3f(0,0,-1);
        glColor4f(1,1,1,1);

        char buf;

        float  x  = - 1;
        float  y  =   0.7;
        float dx  =   0.25;
        float dy  =   0.1;

        for (int i = 0; i <= 15; i++)
        {
            sprintf(&buf, "%8.3f", aMatrix.m[i]);
            glPrint(&buf, x, y, 0);

            y = y - dy;

            if ( (i+1)%4 == 0 )
            {
                x = x + dx;
                y = y + dy*4;
            }
        }
    }
Exemplo n.º 15
0
void glPrLine(int xChar, bool rightAdjust, int line, bool botmAdjust,
    int set, const char *fmt, ...)
{
  char text[256]; /* Holds Our String */
  va_list ap;     /* Pointer To List Of Arguments */
  int xPos, yPos;
  int lineDist = 30;
  int letterDist = 18 + set * 12;

  /* If There's No Text */
  if ( fmt == NULL )
    return;

  va_start( ap, fmt );
  vsprintf( text, fmt, ap );
  va_end( ap );

  if (xChar == PRINT_CENTER)
  {
    int len = strlen(text) * letterDist;
    xPos = (int)(SC_WIDTH / 2 - len / 2);
  }
  else if (rightAdjust)
    xPos = SC_WIDTH - (strlen(text) + xChar) * letterDist;
  else
    xPos = xChar * letterDist;
  if (botmAdjust)
    yPos = line * lineDist;
  else
    yPos = SC_HEIGHT - line * lineDist;
  glPrint(xPos, yPos, set, text);
}
Exemplo n.º 16
0
void GUIButton_Draw(TGUIWidget *AWidget)
{
  TGUIWidgetProperties *BWidgetProperties = (TGUIWidgetProperties *)Widget_GetPointer(AWidget, "prop");
  TGUIButtonProperties *BButtonProperties = (TGUIButtonProperties *)Widget_GetPointer(AWidget, "btn");
  
  if (BWidgetProperties->FEnabled)
  {
    if (BWidgetProperties->FDown)
    {
      glSetColor(BButtonProperties->FColorDown);
    } else
    {
      if (AWidget == AWidget->FWindow->FWidgetMouseOver)
      {
        glSetColor(BButtonProperties->FColorHighlight);
      } else
      {
        glSetColor(BButtonProperties->FColorNormal);
      };
    };
  } else
  {
    glSetColor(BButtonProperties->FColorDisabled);
  };
  glClear(GL_COLOR_BUFFER_BIT);
  glPrint(AWidget->FWindow->FFont, (BWidgetProperties->FWidth / 2) - (glTextWidth(AWidget->FWindow->FFont, BButtonProperties->FText->FPointer) / 2),
                                   (BWidgetProperties->FHeight / 2) + (glTextHeight(AWidget->FWindow->FFont, BButtonProperties->FText->FPointer) / 2),
                                   BButtonProperties->FText->FPointer,
                                   0.0f, 0.0f, 0.0f);
};
Exemplo n.º 17
0
//Utility function to make displaying lines of text on the overlay less messy
void OpenGLRender::rasterStringToOverlay(string str)
{
	glRasterPos2f(1,screenH-16-(overlayLineCount*16));
	const char *c = str.c_str();//new char(str.size()+1);
	//strcpy (c, str.c_str());
	glPrint(c);
	overlayLineCount++;
}
Exemplo n.º 18
0
void
ParamListGL::Render(int x, int y, bool shadow)
{
    beginWinCoords();

    m_start_x = x;
    m_start_y = y;

    for(std::vector<ParamBase *>::const_iterator p = m_params.begin(); p != m_params.end(); ++p) {
        if ((*p)->IsList()) {
            ParamListGL *list = (ParamListGL *) (*p);
            list->Render(x+10, y);
            y += m_separation*list->GetSize();

        } else {
            if (p == m_current)
                glColor3fv(&m_text_color_selected.r);
            else
                glColor3fv(&m_text_color_unselected.r);

            if (shadow) {
                glPrintShadowed(x + m_text_x, y + m_font_h, (*p)->GetName().c_str(), m_font, (p == m_current) ? &m_text_color_selected.r : &m_text_color_unselected.r);
                glPrintShadowed(x + m_value_x, y + m_font_h, (*p)->GetValueString().c_str(), m_font, (p == m_current) ? &m_text_color_selected.r : &m_text_color_unselected.r);
            } else {
                glPrint(x + m_text_x, y + m_font_h, (*p)->GetName().c_str(), m_font);
                glPrint(x + m_value_x, y + m_font_h, (*p)->GetValueString().c_str(), m_font);
            } 

            glColor3fv((GLfloat *) &m_bar_color_outer.r);
            glBegin(GL_LINE_LOOP);
            glVertex2f((GLfloat)(x + m_bar_x)          , (GLfloat)(y + m_bar_offset)          );
            glVertex2f((GLfloat)(x + m_bar_x + m_bar_w), (GLfloat)(y + m_bar_offset)          );
            glVertex2f((GLfloat)(x + m_bar_x + m_bar_w), (GLfloat)(y + m_bar_offset + m_bar_h));
            glVertex2f((GLfloat)(x + m_bar_x)          , (GLfloat)(y + m_bar_offset + m_bar_h));
            glEnd();

            glColor3fv((GLfloat *) &m_bar_color_inner.r);
            glRectf((GLfloat)(x + m_bar_x), (GLfloat)(y + m_bar_offset + m_bar_h), (GLfloat)(x + m_bar_x + ((m_bar_w-1)*(*p)->GetPercentage())), (GLfloat)(y + m_bar_offset + 1));

            y += m_separation;
        }

    }

    endWinCoords();
}
Exemplo n.º 19
0
void getstats(int mode)
{
	if (mode==DD_Check)
	{
		allpolynum=allvertexnum=allobjectnum=alleffectnum=allscenenum=allrendertextureframenum=alleventnum=rendertexnum=0;
		
		for (scene *x=scenelist; x=x->next; x)
		{
			if (x->objects)
			for (object *y=x->objects; y=y->next; y)
			{
				allpolynum+=y->polynum;
				allvertexnum+=y->vertexnum;
				if (y->primitive<100) allobjectnum++;
				else alleffectnum++;
			}
			allscenenum++;
		}
		if (eventlist)
		for (event *e=eventlist; e=e->next; e)
		{
			alleventnum++;
			if (e->eventtype==rendertotext) { allrendertextureframenum+=(e->endframe-e->startframe); rendertexnum++;}
		}
	}
	if (mode==DD_Draw)
	{
		char *s=new char[256];
		memset(s,0,256);
		sprintf(s,"Overall Polycount = %d",allpolynum);
		glRasterPos2i(100,200);
		glPrint(s,base);
		sprintf(s,"Overall Vertexcount = %d",allvertexnum);
		glRasterPos2i(100,220);
		glPrint(s,base);
		sprintf(s,"Overall ObjectCount = %d",allobjectnum);
		glRasterPos2i(100,240);
		glPrint(s,base);
		sprintf(s,"Overall Effectcount = %d",alleffectnum);
		glRasterPos2i(100,260);
		glPrint(s,base);
		sprintf(s,"Overall Scenecount = %d",allscenenum);
		glRasterPos2i(100,280);
		glPrint(s,base);
		sprintf(s,"Overall Eventcount = %d",alleventnum);
		glRasterPos2i(100,300);
		glPrint(s,base);
		sprintf(s,"Overall r2txtframecount = %d",allrendertextureframenum);
		glRasterPos2i(100,320);
		glPrint(s,base);
		sprintf(s,"Overall r2txtcount = %d",rendertexnum);
		glRasterPos2i(100,340);
		glPrint(s,base);
	}
}
Exemplo n.º 20
0
void DrawQuestInfo()
{
     infoQShow--;
     
     glPushMatrix();
     glTranslatef(150,250,0.4);
     
     glBindTexture(GL_TEXTURE_2D,Btn[BtnInfBG].texID);
     glBegin(GL_QUADS);// bg		
     {
	   glTexCoord2i(0, 1);   glVertex2i(0,0);	// Texture / Vertex Coord (Bottom Left)
	   glTexCoord2i(1, 1);   glVertex2i(520,0);	// Texutre / Vertex Coord (Bottom Right)
	   glTexCoord2i(1, 0);	  glVertex2i(520,300);	// Texture / Vertex Coord (Top Right)
	   glTexCoord2i(0, 0);	  glVertex2i(0,300);	// Texture / Vertex Coord (Top Left)
     }
     glEnd();
     glPrint(350,510,"%s", QList[infoQuest].Name);
     glPrint(210,468,"%s", QList[infoQuest].L1);
     glPrint(210,456,"%s", QList[infoQuest].L2);
     glPrint(210,444,"%s", QList[infoQuest].L3);
     glPrint(210,432,"%s", QList[infoQuest].L4);
     glPrint(210,414,"Status: %d", QList[infoQuest].complete);
     if(QList[infoQuest].itemNeeded)
	   glPrint(200,400,"Item needed (No.%d): %s ",QList[infoQuest].itemNeeded, List[QList[infoQuest].itemNeeded].Name);
     glPopMatrix();
}
Exemplo n.º 21
0
void nehewidget::paintGL()
{
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	glBindTexture(GL_TEXTURE_2D, texture[0]);    // 选择字符纹理
	glColor3f(1.0f,0.5f,1.0f);      
	glPrint(207,24,0,"GRID CRAZY");      // 绘制游戏名称"GRID CRAZY"
	glColor3f(1.0f,1.0f,0.0f);     
}
Exemplo n.º 22
0
void CglFont::glFormat(float x, float y, float s, const int options, const char* fmt, ...)
{
	char out[512];
	va_list ap;
	if (fmt == NULL) return;
	va_start(ap, fmt);
	VSNPRINTF(out, sizeof(out), fmt, ap);
	va_end(ap);
	glPrint(x, y, s, options, std::string(out));
}
Exemplo n.º 23
0
void CglFont::glWorldPrint(const float3& p, const float size, const std::string& str)
{
	glPushMatrix();
	glTranslatef(p.x, p.y, p.z);
	glMultMatrixf(camera->GetBillBoardMatrix());
	Begin(false, false);
	glPrint(0.0f, 0.0f, size, FONT_DESCENDER | FONT_CENTER | FONT_OUTLINE, str);
	End();
	glPopMatrix();
}
Exemplo n.º 24
0
void GuiButton::draw() {
    double r = 1.0;
    double g = 0.0;
    double b = 0.0;
    if (!isActive()) {
        r = 0.5;
        g = 0.5;
        b = 0.5;
    } else if (mPressed) {
        r /= 2.0;
        g /= 2.0;
        b /= 2.0;
    }

    if (isVisible()) {
        double glX = getX();
        double glY = getY();
        double glW = getWidth();
        double glH = getHeight();

        glBegin(GL_QUADS);
        glColor3f(r, g, b);
        glVertex2f(glX      , glY      );
        glVertex2f(glX + glW, glY      );
        glVertex2f(glX + glW, glY + glH);
        glVertex2f(glX      , glY + glH);
        glEnd();

        glBegin(GL_LINES);
        glColor3f(0.0, 0.0, 0.0);
        glVertex2f(glX      , glY      );
        glVertex2f(glX      , glY + glH);

        glVertex2f(glX      , glY + glH);
        glVertex2f(glX + glW, glY + glH);

        glVertex2f(glX + glW, glY + glH);
        glVertex2f(glX + glW, glY      );

        glVertex2f(glX + glW, glY      );
        glVertex2f(glX      , glY      );
        glEnd();

		glEnable(GL_SCISSOR_TEST);
		glScissor(glX, glY, glW, glH);
		glColor3f(1.0 - r, 1.0 - g, 1.0 - b);
		double offX = (getWidth() - (double) stringSizeX(getName())) / 2.0;
		double offY = (getHeight() - (double) stringSizeY(getName())) / 2.0;
		glRasterPos2f(getX() + offX
					, getY() + offY);
		glPrint(getName());
		glDisable(GL_SCISSOR_TEST);
    }
    glColor3f(1.0, 1.0, 1.0);
}
int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing|绘制过程:后台
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer|设置颜色为InitGL()中设置的背景色
	glLoadIdentity();									// Reset The View|重置模型观察矩阵
	
	if(RZ - (-15.0f) > 1e-1)							// 加入一个入场动画
	{
		RZ -= 0.05f;
	}
	else
	{
		if(RX - (-5.5f) > 1e-1)
		{
			RX -= 0.01f;
		}
		if(3.2f - RY > 1e-1)
		{
			RY += 0.01f;
		}
	}
	glTranslatef(0.0f,0.0f,RZ);							// 移入屏幕深处15 单位

	glTranslatef(RX,0.0f,0.0f);							// 依据目前的全局X坐标重置Cube位置
    glTranslatef(0.0,RY,0.0);							// 依据目前的全局Y坐标重置Cube位置

   	glRotatef(xrot,1.0f,0.0f,0.0f);						// 绕方向向量(1.0f, 0.0f, 0.0f)即X轴旋转xrot度
    glRotatef(yrot,0.0f,1.0f,0.0f);
    glRotatef(zrot,0.0f,0.0f,1.0f);

    //glColor3f(1.0f, 1.0f, 1.0f);						// 把当前颜色设为白色,否则颜色也与文字一起变化

	// 每次锁定一个2D纹理并对一个Cube进行贴图
	srand(0);
	for(int i = 0; i < M3; i++)
	{
		int r = rand() % CTexture;						// 纹理数量与待贴图四边形数量不一致,随机贴图
		glBindTexture(GL_TEXTURE_2D, texture[r]); 
		DrawObject(i);
	}

    //设置每次沿3个轴转过的角度(整体旋转程序自动控制,全局坐标手动控制)
	xrot += 0.05f;
 	yrot += 0.05f;
  	zrot += 0.05f;

	glColor3f(0.85f-0.15f*float(cos(cnt1)),0.45f-0.05f*float(sin(cnt2)),0.85f-0.15f*float(cos(cnt1+cnt2)));
	// Position The Text On The Screen
	glRasterPos2f(0.5f+0.05f*float(cos(cnt1)), -0.7f+0.32f*float(sin(cnt2)));
 	glPrint("                   Enjoy your online lifestyle - %7.2f", cnt1);
	cnt1 += 0.051f;											// Increase The First Counter
	cnt2 += 0.005f;											// Increase The First Counter
	return TRUE;											// Keep Going
}
Exemplo n.º 26
0
void DrawUI1totexture(double latitude)
{
	char line[128]={0};
	for(int i=-90;i<100;i=i+5)
	{
		sprintf(line,"--------- %3d  ---------",i);
		glPrint(4,(GLint)(124+i*8-latitude*8),line,0);
	}

	glBindTexture(GL_TEXTURE_2D,UItexture1);
	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 256, 256, 0);

}
Exemplo n.º 27
0
int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
	glLoadIdentity();									// Reset The View
	glTranslatef(1.1f*float(cos(rot/16.0f)),0.8f*float(sin(rot/20.0f)),-3.0f);
	glRotatef(rot,1.0f,0.0f,0.0f);						// Rotate On The X Axis
	glRotatef(rot*1.2f,0.0f,1.0f,0.0f);					// Rotate On The Y Axis
	glRotatef(rot*1.4f,0.0f,0.0f,1.0f);					// Rotate On The Z Axis
	glTranslatef(-0.35f,-0.35f,0.1f);					// Center On X, Y, Z Axis
	glPrint("N");										// Draw A Skull And Crossbones Symbol
	rot+=0.1f;											// Increase The Rotation Variable
	return TRUE;										// Keep Going
}
Exemplo n.º 28
0
void nehewidget::paintGL()
{
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	glTranslatef(0.0,0.0,0.0);
	glColor3f(qAbs(1.0f*((float)(cos(cnt1)))),qAbs(1.0f*((float)(sin(cnt2)))),qAbs(1.0f-0.5f*((float)(cos(cnt1+cnt2)))));
	glRasterPos2f(-0.45f+0.05f*float(cos(cnt1)), 0.35f*float(sin(cnt2)));

	glPrint("hello,this is an OpenGL cookbook... -%7.2f",cnt1);
	cnt1+=0.01f;
	cnt2+=0.0081f;
}
Exemplo n.º 29
0
void DrawCredits()
{
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear The Screen And The Depth Buffer
     glLoadIdentity();
     
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glEnable(GL_BLEND);
     glMatrixMode(GL_PROJECTION);					// Select The Projection Matrix
     glPushMatrix();							// Store The Projection Matrix
     glLoadIdentity();						// Reset The Projection Matrix
     glOrtho(0,800,0,600,-1,1);					// Set Up An Ortho Screen
     glMatrixMode(GL_MODELVIEW);					// Select The Modelview Matrix
     
     glBindTexture(GL_TEXTURE_2D,Btn[0].texID);
     
     glBegin(GL_QUADS);// bg		
     {
	  glTexCoord2i(0, 1); 	  glVertex2i(0,0);	// Texture / Vertex Coord (Bottom Left)
	  glTexCoord2i(1, 1); 	  glVertex2i(800,0);	// Texutre / Vertex Coord (Bottom Right)
	  glTexCoord2i(1, 0);	  glVertex2i(800,600);	// Texture / Vertex Coord (Top Right)
	  glTexCoord2i(0, 0);	  glVertex2i(0,600);	// Texture / Vertex Coord (Top Left)
     }
     glEnd();
     
     glPrint(300,500,"Created by Gediminas Skucas");
     
     glPrint(300,450,"KTU, 2010");
        
     glMatrixMode(GL_PROJECTION);				// Select The Projection Matrix
     glPopMatrix();						// Restore The Old Projection Matrix
     glMatrixMode(GL_MODELVIEW);				// Select The Modelview Matrix
     
     glFlush();	
     glDisable(GL_BLEND);
     glBlendFunc(GL_DST_COLOR, GL_ZERO);
     
     glutSwapBuffers();
     
}
Exemplo n.º 30
0
void desenha_info_objeto(string info)
{

  if (info == "")
    return;

  double initial_x = -2.8, initial_y = -1.35, initial_z = -3.5;

  double font_height = 0.15;

  char str_to_print[4096];
  strncpy(str_to_print, info.c_str(), 4095);

  glMatrixMode(GL_MODELVIEW);

  glPushMatrix();
  glLoadIdentity();

  glColor4f(1.0, 1.0, 1.0, ALPHA);

  glEnable(GL_TEXTURE_2D);			// Enable Texture Mapping

  glBindTexture(GL_TEXTURE_2D, texture[INFO_BOX_BACKG]);

  glBegin (GL_POLYGON);
       glTexCoord2f(0.0f, 1.0f); glVertex3f (-3.3, -2.5, -4);
       glTexCoord2f(0.0f, 0.0f); glVertex3f (-3.3, -1.2, -4);
       glTexCoord2f(1.0f, 0.0f); glVertex3f (-1.4,  -1.2, -4);
       glTexCoord2f(1.0f, 1.0f); glVertex3f (-1.4,  -2.5, -4);
  glEnd();

  glDisable(GL_TEXTURE_2D);


  glColor3f(0.68, 0.9, 0.59);

  int line=0;
  char *cur_line;

  cur_line = strtok (str_to_print, "\n");
  while (cur_line != NULL)
  {
    glRasterPos3f(initial_x, initial_y-(line*font_height), initial_z);
    glPrint(cur_line);
    cur_line = strtok (NULL, "\n");
    line += 1;
  }

  glPopMatrix();

}