Example #1
0
void mdisplay()
{
	glClear(GL_COLOR_BUFFER_BIT);

	char* fix = "Fixed";
	char* moving = "Moving";

	glColor3d(0, 0, 0);
	glBegin(GL_QUADS);
	glVertex2d(width / 2, 0);
	glVertex2d(width / 2, height);
	glVertex2d(isFixed ? width : 0, height);
	glVertex2d(isFixed ? width : 0, 0);
	glEnd();
	// draw title
	glColor3d(1, 1, 1);
	glRasterPos2d(width / 2.6, height / 4);
	for (char* str = title; *str; str++) {
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *str);
	}
	glRasterPos2d(width / 5, height * 3 / 5);
	for (char* str = fix; *str; str++) {
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *str);
	}
	glRasterPos2d(width * 2 / 3, height * 3 / 5);
	for (char* str = moving; *str; str++) {
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *str);
	}

	glutSwapBuffers();
}
static __inline__ void g2x_InitPopOn()
{
	G2Xpopup* pop=_POPUP_;
	char* c;
	int   len;

	while (pop<_POPUP_+popnum)
	{
		pop->idon = glGenLists(1);
		glNewList(pop->idon, GL_COMPILE);
			glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    	glBegin(GL_TRIANGLE_FAN);  
      	glColor4f(0.3,0.4,0.5,1.);
      	glVertex2i(0,0);
      	glColor4f(0.9,0.9,1.0,1.);
      	glVertex2i(-Xbutw,-8);
      	glVertex2i(-Xbutw,+8);
      	glVertex2i(+Xbutw,+8);
      	glVertex2i(+Xbutw,-8);
      	glVertex2i(-Xbutw,-8);
    		glEnd();
			len=0;
			for (c=pop->name; *c!='\0'; c++) len+=glutBitmapWidth(GLUT_BITMAP_HELVETICA_10,*c);
    	len=-len/2; glRasterPos2i(len,-4); 
    	glColor4fv(G2Xw);
    	for (c=pop->name; *c!='\0'; c++) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10,*c);
    	len++;      glRasterPos2i(len,-4); 
    	glColor4fv(G2Xwc);
    	for (c=pop->name; *c!='\0'; c++) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10,*c);
  	glEndList();
		pop++;
	}
}
Example #3
0
void GLUTDrawText(const R3Point& p, const char *s)
{
  // Draw text string s and position p
  glRasterPos3d(p[0], p[1], p[2]);
#ifndef __CYGWIN__
  while (*s) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *(s++));
#else
  while (*s) glutBitmapCharacter((void*)7, *(s++));
#endif
}
static __inline__ void g2x_InitCornSwitchOff()
{
	_info_id_off_ = glGenLists(1);
  glNewList(_info_id_off_, GL_COMPILE);
		int x=-glutBitmapWidth(GLUT_BITMAP_HELVETICA_18,'?')/2;
	  glColor4fv(G2Xwb);
    glRasterPos2i(x+1,-5);glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,'?');
	  glColor4fv(G2Xk);
    glRasterPos2i(x-1,-5);glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,'?');
  glEndList();
}
Example #5
0
 static int __glutBitmapCharacter(OS * os, int params, int, int, void*)
 {
     if(params >= 2) {
         if(os->getType(-params + 0) == OS_VALUE_TYPE_NUMBER) {
             int std_font = os->toInt(-params + 0);
             glutBitmapCharacter((void*)std_font, os->toInt(-params + 1));
             return 0;
         }
         OS::String str = os->toString(-params + 0);
         glutBitmapCharacter((void*)str.toChar(), os->toInt(-params + 1));
     }
     return 0;
 }
Example #6
0
void DrawText(int x, int y, char const *string)
{
	int len, i;

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	int w = glutGet(GLUT_WINDOW_WIDTH);
	int h = glutGet(GLUT_WINDOW_HEIGHT);
	gluOrtho2D(0, w, h, 0);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();

	glColor3f(0.9f, 0.6f, 0.6f);
	glRasterPos2i(x, y);
	len = (int) strlen(string);
	for (i = 0; i < len; i++)
		glutBitmapCharacter(GLUT_BITMAP_9_BY_15, string[i]);

	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
}
   void ElevatorSimRenderWindow::drawText(char *str, float x, float y)
   {
      glDisable(GL_DEPTH_TEST);
      glPushAttrib(GL_LIGHTING_BIT);
      glDisable(GL_LIGHTING);
      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      glLoadIdentity();
      gluOrtho2D(0, w(), 0, h());
      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glLoadIdentity();

      glRasterPos2f(x, y);

      char *c;
      for (c=str; *c != '\0'; c++) {
         glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, *c);
      }

      glPopMatrix();
      glMatrixMode(GL_PROJECTION);
      glPopMatrix();
      glMatrixMode(GL_MODELVIEW);
      glPopAttrib();
      glEnable(GL_DEPTH_TEST);
   }
Example #8
0
void GUILabel::render(bool bSetColor)
{
	if (bSetColor)
	{
		if (m_bMouseOver)
		{
			glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
		}
		else
		{
			glColor4f(m_Color[0], m_Color[1], m_Color[2], m_Color[3]);
		}
	}

	glRasterPos2i(m_X, m_Y);

	char* tempPtr = m_pTitle;
	while (*tempPtr)        
	{
		glutBitmapCharacter((void *)m_Font, *tempPtr++);
	}

	if (bSetColor)
	{
		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	}
}
Example #9
0
static void
DrawText(const R3Point& p, const char *s)
{
  // Draw text string s and position p
  glRasterPos3d(p[0], p[1], p[2]);
  while (*s) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, *(s++));
}
Example #10
0
void Write(char *string)
{
    while(*string)
    {
                   glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *string++);
    }
}
Example #11
0
void OSDGlutDisplayMessage(OSDMessage_struct * message)
{
    int LeftX=9;
    int Width=500;
    int TxtY=11;
    int Height=13;
    int i, msglength;
    int vidwidth, vidheight;

    VIDCore->GetGlSize(&vidwidth, &vidheight);
    Width = vidwidth - 2 * LeftX;

    switch(message->type) {
    case OSDMSG_STATUS:
        TxtY = vidheight - (Height + TxtY);
        break;
    }

    msglength = strlen(message->message);

    glBegin(GL_POLYGON);
    glColor3f(0, 0, 0);
    glVertex2i(LeftX, TxtY);
    glVertex2i(LeftX + Width, TxtY);
    glVertex2i(LeftX + Width, TxtY + Height);
    glVertex2i(LeftX, TxtY + Height);
    glEnd();

    glColor3f(1.0f, 1.0f, 1.0f);
    glRasterPos2i(10, TxtY + 11);
    for (i = 0; i < msglength; i++) {
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, message->message[i]);
    }
    glColor3f(1, 1, 1);
}
Example #12
0
//
//  テキストを描画
//
void  drawMessage( int line_no, const char * message )
{
	int   i;
	if ( message == NULL )
		return;

	// 射影行列を初期化(初期化の前に現在の行列を退避)
	glMatrixMode( GL_PROJECTION );
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D( 0.0, win_width, win_height, 0.0 );

	// モデルビュー行列を初期化(初期化の前に現在の行列を退避)
	glMatrixMode( GL_MODELVIEW );
	glPushMatrix();
	glLoadIdentity();

	// Zバッファ・ライティングはオフにする
	glDisable( GL_DEPTH_TEST );
	glDisable( GL_LIGHTING );

	// メッセージの描画
	glColor3f( 1.0, 0.0, 0.0 );
	glRasterPos2i( 8, 24 + 18 * line_no );
	for ( i=0; message[i]!='\0'; i++ )
		glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, message[i] );

	// 設定を全て復元
	glEnable( GL_DEPTH_TEST );
	glEnable( GL_LIGHTING );
	glMatrixMode( GL_PROJECTION );
	glPopMatrix();
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();
}
Example #13
0
static void print(const char *text, const float x, const float y, int calculateXFromRightEdge, int calculateYFromTopEdge)
{
    int     i, len;
    GLfloat x0, y0;

    if (!text)
        return;

    if (calculateXFromRightEdge)
    {
        x0 = windowWidth - x - (float)glutBitmapLength(GLUT_BITMAP_HELVETICA_10, (const unsigned char*)text);
    }
    else
    {
        x0 = x;
    }

    if (calculateYFromTopEdge)
    {
        y0 = windowHeight - y - 10.0f;
    }
    else
    {
        y0 = y;
    }

    glRasterPos2f(x0, y0);

    len = (int)strlen(text);

    for (i = 0; i < len; i++)
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, text[i]);
}
Example #14
0
void drawOverlay()
{
  // Draw Overlay
  glColor4f(1.0, 1.0, 1.0, 1.0);
  glPushAttrib(GL_LIGHTING_BIT);
     glDisable(GL_LIGHTING);

     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     gluOrtho2D(0.0, 1.0, 0.0, 1.0);

     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
     glRasterPos2f(0.01, 0.01);
     
     char info[1024];
     sprintf(info, "Framerate: %3.1f  |  Frame: %u  |  %s", 
         theFpsTracker.fpsAverage(), theSmokeSim.getTotalFrames(),
         theSmokeSim.isRecording()? "Recording..." : "");
 
     for (unsigned int i = 0; i < strlen(info); i++)
     {
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, info[i]);
     }
  glPopAttrib();
}
Example #15
0
	void Fps::showFps() {
		glColor3d(red, green, blue);
		sprintf_s(f, "%d", realFps());

		glRasterPos2f(x, y);

		//string = text_after_fps;
		for (c = text_after_fps; *c != '\0'; c++) {
			glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *c);
		}

		//string = f;
		for (c = f; *c != '\0'; c++) {
			glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *c);
		}
	}
Example #16
0
void drawString(int x, int y, char *str, COLOR color)
{
	glColor3f(color.red, color.green, color.blue);
	glRasterPos2i(x, y);
	for( str; *str != '\0'; str++ )
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, *str);
}
Example #17
0
static void DrawString(char str[], int w, int h, int x0, int y0)
{
	//glDisable(GL_LIGHTING);
	// 平行投影にする
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	gluOrtho2D(0, w, h, 0);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();

	// 画面上にテキスト描画
	glRasterPos2f(x0, y0);
	int size = 0;
	while (str[size] != 0x00){
		size++;
	}

	for (int i = 0; i < size; ++i){
		char ic = str[i];
		glutBitmapCharacter(GLUT_BITMAP_9_BY_15, ic);
	}

	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
}
Example #18
0
void display(void) {
	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	int w = glutGet((GLenum)GLUT_WINDOW_WIDTH);
	int h = glutGet((GLenum)GLUT_WINDOW_HEIGHT);
	glViewport(0, 0, w, h);
	glDisable(GL_CULL_FACE);
	
	// Set our shaderprogram and then draw the triangles that contains the raytraced texture/image.
	//TODO: Actually draw a texture.............
	glUseProgram(defShaderProgram);
	glBindVertexArray(vertexArrayObject);
	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	glUseProgram(0);

	// Print fps in bottom left corner
	std::string fpsString = std::to_string(fps);
	for (int i = 0; i < fpsString.length(); i++) {
		glWindowPos2i(i*12, 0);
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, fpsString[i]);
	}

	glutSwapBuffers();
}
Example #19
0
void drawText3D(void *pFont, double x0, double y0, const char* pString)
//-----------------------------------------------------------------------------
//  Using the specified font, write the text in 'pString' to the display window
// at location x0,y0 in the current 3D coord system using the current color.
// CAREFUL! This is trickier to use than drawText2D()!
// CAREFUL! It ASSUMES that lighting is NOT enabled--if it is, you usually won't
// see any on-screen text.
// CAREFUL! Some or all of your text might be hiding inside a 3D object! e.g. if
// you put text at the origin of the current coord system (x0,y0,z) = (0,0,0)
// enable openGL's depth-testing, AND draw a teapot at that origin, then some or
// all of your text may hide inside!
//      Usage example:
//              glDisable(GL_LIGHTING);     // turn OFF lighting temporarily
//              glColor3d(1.0,1.0,0.0);     // bright yellow color
//              drawText3D(helv18, 0.3,0.4 ,"Hello!");  // print text in 3D;
//              glEnable(GL_LIGHTING);      // re-enable openGL lighting.
//
// Available fonts:
// helv10 (HELVETICA size 10)   rom10 (TIMES_ROMAN size 10)
// helv12 (HELVETICA size 12)   rom24 (TIMES_ROMAN size 24)
// helv18 (HELVETICA size 18)
{
int i, imax;					// character counters

	glRasterPos2d(x0, y0);		// set text's lower-left corner position
	imax = 1023;				// limit the number of chars we print.
	for(i=0; pString[i] != '\0' && i<imax; i++)	// for each char,
	{
		glutBitmapCharacter(pFont, pString[i]);
	}
}
static __inline__ void g2x_InitSwitchOn()
{
	G2Xswitch* swt=_SWITCH_;
	char* c;
	int   x,y,yy, r = 12;
	float d,e, rr= 128., irr= 0.0078125;
	while (swt<_SWITCH_+switchnum)
	{
		swt->idon = glGenLists(1);
  	glNewList(swt->idon, GL_COMPILE);
			glBegin(GL_POINTS);
  		for (y=-r; y<=+r; y++)
			{
				yy=y*y;
    		for (x=-r; x<=+r; x++)
    		{
 			 		if ((d=(float)(x*x+yy))>rr) continue;
			 		d=d*irr;
					e=pow((1.-d),3);
					d=0.5*pow(d,4);
			 		glColor4f(d,1.,d,e);
			 		glVertex2i(x,y);
    		}
			}	
			glEnd();
    	glColor4fv(G2Xk);
    	glRasterPos2i(+12,-4); 
    	for (c=swt->name; *c!='\0'; c++) glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10,*c);
  	glEndList();
		swt++;
	}
}
Example #21
0
File: FPS.cpp Project: AM1244/Blog
//-------------------------------------------------------------------------
//  Draws a string at the specified coordinates.
//-------------------------------------------------------------------------
void printw (float x, float y, float z, char* format, ...)
{
	va_list args;	//  Variable argument list
	int len;		//	String length
	int i;			//  Iterator
	char * text;	//	Text

	//  Initialize a variable argument list
	va_start(args, format);

	//  Return the number of characters in the string referenced the list of arguments.
	//  _vscprintf doesn't count terminating '\0' (that's why +1)
	len = _vscprintf(format, args) + 1; 

	//  Allocate memory for a string of the specified size
	text = (char *)malloc(len * sizeof(char));

	//  Write formatted output using a pointer to the list of arguments
	vsprintf_s(text, len, format, args);

	//  End using variable argument list 
	va_end(args);

	//  Specify the raster position for pixel operations.
	glRasterPos3f (x, y, z);

	//  Draw the characters one by one
    for (i = 0; text[i] != '\0'; i++)
        glutBitmapCharacter(font_style, text[i]);

	//  Free the allocated memory for the string
	free(text);
}
Example #22
0
void InfoDisplayer::renderInfo(int _position, string const & _str)
{
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
	glTranslatef(0.0, 0.0, 0.9);

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(-1, 1, -1, 1, -1, 1);

	{
		float positionX = -0.98;
		float positionY = 0.05 * (_position + 1) - 1; 

		glRasterPos2f(positionX, positionY);
		for(string::size_type i = 0; i < _str.size(); i++)
		{
			glutBitmapCharacter(GLUT_BITMAP_9_BY_15, _str[i]);
		}
	}

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
}
Example #23
0
//----------------------------------------------------------------------------------------------
void DebugDraw::DrawString(int x, int y, const char *string, ...)
{
    char buffer[128];

    va_list arg;
    va_start(arg, string);
    vsprintf(buffer, string, arg);
    va_end(arg);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    int w = glutGet(GLUT_WINDOW_WIDTH);
    int h = glutGet(GLUT_WINDOW_HEIGHT);
    gluOrtho2D(0, w, h, 0);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();

    glColor3f(0.9f, 0.6f, 0.6f);
    glRasterPos2i(x, y);
    int32 length = (int32)strlen(buffer);
    for (int32 i = 0; i < length; ++i)
    {
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, buffer[i]);
        //glutBitmapCharacter(GLUT_BITMAP_9_BY_15, buffer[i]);
    }

    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
}
Example #24
0
static void drawFPS(double fpsRate)
{
  GLubyte dummy;
  char buffer[200], *c;

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
      glLoadIdentity();
      glOrtho(0, 1, 1, 0, -1, 1);
      //glDisable(GL_DEPTH_TEST);
      glColor3fv(textColor);
      glRasterPos2f(1,1);
      glBitmap(0, 0, 0, 0, -10*9, 15, &dummy);
      if (fpsRate > 0 || !validFPS) {
        sprintf(buffer, "fps %0.1f", fpsRate);
      } else {
        strcpy(buffer, "fps --");
      }
      for (c = buffer; *c != '\0'; c++)
        glutBitmapCharacter(GLUT_BITMAP_9_BY_15, *c);
      //glEnable(GL_DEPTH_TEST);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
  glPopMatrix();
}
Example #25
0
static void DrawBitmapString(void *font, const char *string)
{
    int i;

    for (i = 0; string[i]; i++)
	glutBitmapCharacter(font, string[i]);
}
Example #26
0
void Win::Draw_() const
{
	glClearColor(0.0,0.0,0.0,0.0);
	glClear(GL_COLOR_BUFFER_BIT);
	glColor4f(1.0,0.0,0.0,1.0);
	glBegin(GL_LINE_LOOP);
	glVertex3f(0,0,0);
	glVertex3f(WIN_WIDTH,0,0);
	glVertex3f(WIN_WIDTH,WIN_HEIGHT,0);
	glVertex3f(0,WIN_HEIGHT,0);
	glEnd();
	glFlush();

	if (status)
	{
		Block block;
		for (int i=0;i<num_row;i++)
			for (int j=0;j<num_col;j++)
				if (map[i][j])
				{
					block.Set_pos(i,j);
					block.Draw_();
				}
	}else{
		char string[]="GAME OVER";
		int len;
		
		glRasterPos2f(WIN_WIDTH/2-50,WIN_HEIGHT/2);

		len = (int) strlen(string);
		for (int i=0;i<len;i++)
		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18,string[i]);
	}
}
Example #27
0
// String rendering routine; leverages on GLUT routine.
static void ourPrintString(void *font, char *str)
{
    int i,l=strlen(str);

    for(i=0; i<l; i++)
        glutBitmapCharacter(font,*str++);
}
Example #28
0
void display()
{
int i=0;
glClear(GL_COLOR_BUFFER_BIT);
buret();
glPushMatrix();
glutTimerFunc(400,update,0);
glTranslated(a,b,0.0);
dro();
glutPostRedisplay();
glPopMatrix();
glPushMatrix();
glTranslated(c,d,0.0);
conical();
scanfill1(75,25,78,22,122,22,125,25);
glutPostRedisplay();
glPopMatrix();
scanfill(94,185,106,185,106,111,94,111);
scanfill(95,111,107,111,103,90,99,90);
scanfill(95,111,103,90,101,80,101,80);
sprintf(125,100,"conical");
glColor3f(1.0,1.0,1.0);
glRasterPos2i(100,120);
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12,"L");
glFlush();
}
Example #29
0
static void PrintString(const char* const text) {
  void* const font = GLUT_BITMAP_9_BY_15;
  int i;
  for (i = 0; text[i]; ++i) {
    glutBitmapCharacter(font, text[i]);
  }
}
Example #30
0
void obj::scene::render_string(char * string, float x, float y, float r, float g, float b) {
    for (unsigned int i = 0; i < strlen(string); i++) {
        glRasterPos2f(x, y);
        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, string[i]);

        x += 14;
    }
}