Пример #1
0
//Draws Screen based On Menu Code
void drawMenu(bool gettingName, string inputText, const Uint8* keyState){
    glEnable2D();
    glColor3f(1, 1, 1);
    glBindTexture(GL_TEXTURE_2D, mTexture[0]);
    glBegin(GL_QUADS);
        glTexCoord2d(0, 1); glVertex3d(0, 720, 0);
        glTexCoord2d(1, 1); glVertex3d(1280, 720, 0);
        glTexCoord2d(1, 0); glVertex3d(1280, 0, 0);
        glTexCoord2d(0, 0); glVertex3d(0, 0, 0);
    glEnd();
    
    glColor3f(0, 0, 0);
    glRenderText(title, 0, 0, 0, 310, 560, "DOOM in a Room");
    if(gettingName) name(inputText);
    if(!gettingName){
        if(keyState[SDL_SCANCODE_M]) menuCode = "menu";
        if(menuCode == "menu") menu();
        if(keyState[SDL_SCANCODE_H]) menuCode = "highscores";
        if(menuCode == "highscores") highscores();
        if(keyState[SDL_SCANCODE_C]) menuCode = "controls";
        if(menuCode == "controls") controls();
    }
    
    glDisable2D();
}
void FontRenderer::glPrint(int x, int y, const char *fmt, ...) {
	char text[256]; /* Holds our string */
	va_list ap; /* Pointer to our list of elements */

	/* If there's no text, do nothing */
	if (text == NULL)
		return;

	/* Parses The String For Variables */
	va_start(ap, fmt);
	/* Converts Symbols To Actual Numbers */
	vsprintf(text, fmt, ap);
	va_end(ap);

	glEnable2D();
	glDisable(GL_DEPTH_TEST);

	position.x = x;
	position.y = y;

	drawText(text, font, color, &position);

	glEnable(GL_DEPTH_TEST);
	glDisable2D();
}
Пример #3
0
//Draws HUD
//  Gun, Health, and Score are displayed
void Player::drawHUD() {
    sprintf(buffer, "%d", score);
    tmp = buffer;
    s = "SCORE: " + tmp;

    sprintf(buffer, "%d", health);
    tmp = buffer;
    h = "HEALTH: " + tmp;

    glEnable2D();
    glBindTexture(GL_TEXTURE_2D, gunTex[gunTexIndex]);
    glBegin(GL_QUADS);
    glTexCoord2d(0, 1);
    glVertex3d(515, 0, 0);
    glTexCoord2d(1, 1);
    glVertex3d(765, 0, 0);
    glTexCoord2d(1, 0);
    glVertex3d(765, 250, 0);
    glTexCoord2d(0, 0);
    glVertex3d(515, 250, 0);
    glEnd();

    glRenderText(font, 255, 0, 0, 0, 665, s);
    glRenderText(font, 255, 0, 0, 0, 0, h);
    glDisable(GL_BLEND);

    glDisable2D();
}
Пример #4
0
void				render_selection_box(t_data *data, t_selection *s)
{
	glEnable2D(&data->camera.x, &data->camera.y);
		glBegin(GL_LINE_LOOP);
			glVertex2f(s->sx, s->sy);
			glVertex2f(s->cx, s->sy);
			glVertex2f(s->cx, s->cy);
			glVertex2f(s->sx, s->cy);
		glEnd();
	glDisable2D();
}
Пример #5
0
void	cBattlePhase::Render()
{
	glEnable2D(cGameApp::m_svGameResolution.x,cGameApp::m_svGameResolution.y);
	if( m_pBattleAttack )
		m_pBattleAttack->Render();
	if( m_pBattleDefence )
		m_pBattleDefence->Render();
	m_pMainRoleData->Render();
	if( m_pMonsterBase )
		m_pMonsterBase->Render();
}
Пример #6
0
void				render_wizard(t_data *data, t_wizard *wizard)
{
	glEnable2D(&data->camera.x, &data->camera.y);
		glBindTexture(GL_TEXTURE_2D, data->textures[wizard->tx_id]);
		glTranslatef(wizard->cx, wizard->cy, 0.0f);
		glRotatef(wizard->angle, 0.0f, 0.0f, 1.0f);
		glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 0.0f);
			glVertex2f(-wizard->width, -wizard->height);
			glTexCoord2f(1.0f, 0.0f);
			glVertex2f(wizard->width, -wizard->height);
			glTexCoord2f(1.0f, 1.0f);
			glVertex2f(wizard->width, wizard->height);
			glTexCoord2f(0.0f, 1.0f);
			glVertex2f(-wizard->width, wizard->height);
		glEnd();
		glBindTexture(GL_TEXTURE_2D, 0);
	glDisable2D();
}
Пример #7
0
static void initGL() {
	glEnable2D();
}
Пример #8
0
void Editor::draw()
{

	if(!valid())
	{
		// initialize opengl
		valid(1);
		InitScene();
		printf("INITIALIZED\n");
		bounds = new Rectangle(MARGIN_LEFT, h() - MARGIN_BOTTOM, bounds->width,  bounds->height);

		if (!menu_items) {
			// populate menu items
			int rows = menu->height / col_h;
			int cols = menu->width / row_w;
			int item_count = 0;
			Rectangle menu_ptr = Rectangle(menu->left(), menu->bottom() + col_h, row_w, col_h);
			menu_items = new AbstractThing*[rows * cols];
			for (int i = 0; i < rows * cols; i++){
				menu_items[i] = NULL;
			}
			
			for (int j = 0; j < rows; j++) {
				for (int i = 0; i < cols; i++) {	                      
					if (item_count >= TYPE_COUNT)
						break;
					
					while (item_count == TYPE_DOOR || item_count == TYPE_HERO)
						item_count++;
					
					menu_items[item_count] = getThingFromCode(item_count, menu_ptr.position_x, menu_ptr.position_y,
															  row_w, col_h, m_UI->sprites);
					menu_items[item_count]->SetBounds(menu_ptr.position_x, menu_ptr.position_y,row_w, col_h);
					printf("added menu item %d, %s.\n", item_count, menu_items[item_count]->ToString());
					item_count++;
					menu_ptr.position_x += row_w;
				}
				menu_ptr.position_y += col_h;
				menu_ptr.position_x = menu->left();
			}
		}
	}

	// move
	moveCurser();
	
	
	// Draw Scene
	glEnable2D();
	glDrawBuffer(GL_BACK);

	// Draw Backdrop
	glBindTexture(GL_TEXTURE_2D, m_UI->sprites->getSprite(SPRITE_BACKGROUND));
	bounds->draw();
	glBindTexture(GL_TEXTURE_2D, 0);

	// draw placed items
	for (AbstractThing *thing : *placed_items) {
		if (thing->gen_type != NONSOLID && thing->gen_type != COLLECTABLE)
		thing->draw();
	}
	if (hero)
		hero->draw();
	if (door)
		door->draw();

	// draw placed collectables
	for (AbstractThing *thing : *placed_items) {
		if (thing->gen_type == COLLECTABLE)
		thing->draw();
	}

	// draw placed non solids
	for (AbstractThing *thing : *placed_items) {
		if (thing->gen_type == NONSOLID)
		thing->draw();
	}


	glBindTexture(GL_TEXTURE_2D, 0);

	// draw menu
	if (choosing) {
		DrawMenu();
	}
	
	// draw curser
	glPushMatrix();
		glColor4f(1,0,0, 1);
		glLineWidth(3);	     
		glBegin(GL_LINES);                                         
			glVertex2f( curser->left(), curser->top() );                           
			glVertex2f( curser->left(), curser->bottom() ); 
			glVertex2f( curser->left(), curser->bottom() );
			glVertex2f( curser->right(), curser->bottom() );
			glVertex2f( curser->right(), curser->bottom() );  
			glVertex2f( curser->right(), curser->top() );
			glVertex2f( curser->right(), curser->top() );
			glVertex2f( curser->left(), curser->top() ); 
		glEnd();
		glColor4f(1,1,1, 1);
	glPopMatrix();
	glDisable2D();
}
Пример #9
0
void				render_wizard_destination(t_data *data, float *x, float *y, float r, int fragments)
{
	glEnable2D(&data->camera.x, &data->camera.y);
		draw_circle(*x, *y, r, fragments);
	glDisable2D();
}
Пример #10
0
void				render_selection(t_data *data, float *x, float *y, float *w, float *h)
{
	glEnable2D(&data->camera.x, &data->camera.y);
		draw_circle(*x, *y, (*w + *h) / 2, 20);
	glDisable2D();
}
Пример #11
0
void				render_wizard_destination_vector(t_data *data, float x1, float y1, float x2, float y2)
{
	glEnable2D(&data->camera.x, &data->camera.y);
		draw_line(x1, y1, x2, y2);
	glDisable2D();
}
Пример #12
0
/**
 * Just the current frame in the display.
 */
static
void
engine_draw_frame( struct ENGINE* engine )
{
	if( engine->display == NULL )
	{
		LOGI( "!!! NO DISPLAY !!! engine_draw_frame" );
		return;
	}

	int i;
	int vPort[4];
	glGetIntegerv( GL_VIEWPORT, vPort );

	// Just fill the screen with a color.
	glClearColor( 0, 0, 0, 0 );
	glClear( GL_COLOR_BUFFER_BIT );

	glShadeModel( GL_FLAT );

	glVertexPointer( 2, GL_FLOAT, 0, square );

	glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

	glEnable2D();
	for( i = 0; i < 64; ++i )
	{
		if( engine->touchstate_screen[i].down == 0 )
			continue;

		glPushMatrix();
			glTranslatef( engine->touchstate_screen[i].x, vPort[3]-engine->touchstate_screen[i].y ,0.0f );
			glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
		glPopMatrix();
	}

	//used to scale the values down to 0->1.0f
	static const float padx_scale = 1.0f/966.0f;
	static const float pady_scale = 1.0f/360.0f;
	glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
	for( i = 0; i < 64; ++i )
	{
		if( engine->touchstate_pad[i].down == 0 )
			continue;

		glPushMatrix();
			//once the touchpad values are scaled down to 0->1 we can scale them up to the 
			//screen resolution.
			glTranslatef(	((float)vPort[2]) * (((float)engine->touchstate_pad[i].x) * padx_scale),
							((float)vPort[3]) * (((float)engine->touchstate_pad[i].y) * pady_scale),
							0.0f );
			glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
		glPopMatrix();
	}

	glDisable2D();

	glFlush();

	eglSwapBuffers( engine->display, engine->surface );
}