Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Displaying a 2D Image


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 aanthonyz1   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 January 2013 - 12:53 PM

Ok so I have a OpenGL application that displays a AVI, so far I have that working. Now I am trying to have it display a 2D Image. My program inceases "phase" everytime I press the enter key and when it is at phase 1, it should display a 2D image but it isnt working, 

 

This is my update function:

void Update (DWORD milliseconds)								// Perform Motion Updates Here
{
	if (g_keys->keyDown [VK_ESCAPE] == TRUE)					// Is ESC Being Pressed?
	{
		TerminateApplication (g_window);						// Terminate The Program
	}

	if (g_keys->keyDown [VK_F1] == TRUE)						// Is F1 Being Pressed?
	{
		//ToggleFullscreen (g_window);							// Toggle Fullscreen Mode
		OpenAudio();
	}
	if(g_keys->keyDown [VK_RETURN] == TRUE)
	{
		phase++;
	}
	next+=milliseconds;											// Increase next Based On The Timer
	frame=next/mpf;												// Calculate The Current Frame

	if (frame>=lastframe)										// Are We At Or Past The Last Frame?
	{
		frame=0;												// Reset The Frame Back To Zero (Start Of Video)
		next=0;													// Reset The Animation Timer (next)
	}
}

 

This is my actual drawing

 

void Draw (void)												// Draw Our Scene
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear Screen And Depth Buffer
	switch(phase)
	{
	case 0:
	GrabAVIFrame(frame);										// Grab A Frame From The AVI

	if (bg)														// Is Background Visible?
	{
		glLoadIdentity();										// Reset The Modelview Matrix
		glBegin(GL_QUADS);										// Begin Drawing The Background (One Quad)
			// Front Face
			glTexCoord2f(1.0f, 1.0f); glVertex3f( 15.3f,  8.3f, -20.0f);
			glTexCoord2f(0.0f, 1.0f); glVertex3f(-15.3f,  8.3f, -20.0f);
			glTexCoord2f(0.0f, 0.0f); glVertex3f(-15.3f, -8.3f, -20.0f);
			glTexCoord2f(1.0f, 0.0f); glVertex3f( 15.3f, -8.3f, -20.0f);
		glEnd();												// Done Drawing The Background
	}
	break;
	case 1:

	glBindTexture( GL_TEXTURE_2D, texture );

      glBegin( GL_QUADS );
      glTexCoord2f(1.0f, 1.0f); glVertex3f( 15.3f,  8.3f, -20.0f);
			glTexCoord2f(0.0f, 1.0f); glVertex3f(-15.3f,  8.3f, -20.0f);
			glTexCoord2f(0.0f, 0.0f); glVertex3f(-15.3f, -8.3f, -20.0f);
			glTexCoord2f(1.0f, 0.0f); glVertex3f( 15.3f, -8.3f, -20.0f);
      glEnd();
	break;
	}

	
	glFlush ();													// Flush The GL Rendering Pipeline
}

 

Any help would be appreciated



Sponsor:

#2 aanthonyz1   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 January 2013 - 10:54 PM

Anyone?



#3 L. Spiro   Crossbones+   -  Reputation: 16592

Like
0Likes
Like

Posted 31 January 2013 - 12:05 AM

Judging by the names of your code, phase is increased beyond 1 quite rapidly, since the name of that array suggests it is increased every frame as long as the key is held.

Only increase it when the key is pressed, not held.

 

Additionally, don’t call glFlush() ever unless you have a very specific reason to do so.

Also additionally too as well, don’t bother even learning immediate mode (glBegin()/glEnd()).  It should never have even existed in the first place and you are only wasting time your time by learning/using it, since you will end up learning/using VBO’s either way.  Why not skip to the end?

 

 

L. Spiro






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS