Jump to content


Photo
- - - - -

Stretching 2D


  • Please log in to reply
5 replies to this topic

#1 aqrit

aqrit

    Member

  • Members
  • 80 posts

Posted 13 April 2012 - 04:43 PM

I aplogize in advance for this question:

How can a 640x480 movie be stretched to fill the 800x600 window?

I'm thinking: hook SwapBuffers and copy a rect from the back buffer to the front buffer
This snippet doesn't work:
glReadBuffer( GL_BACK );
glDrawBuffer( GL_FRONT );
//glPixelZoom??
glCopyPixels( 400, 300, 300, 300, GL_COLOR );
glDrawBuffer( GL_BACK );

I have the function that draws the movie...
Should I be going after some other OpenGl function (like glTexCoord2f) ?

The game is Baldur's Gate II: Throne of Bhaal version 26498
configured to run windowed at 800x600 OpenGl ( already solved for DirectDraw )

and here are my notes on the matter:
Spoiler


#2 KEMiCZA

KEMiCZA

    Administrator

  • Administrators
  • 400 posts
  • LocationBelgium

Posted 13 April 2012 - 10:42 PM

I found this snippet of code on nehe's opengl site, from tutorial 2

GLvoid ReSizeGLScene(GLsizei width, GLsizei height)  // Resize And Initialize The GL Window
{
if (height==0)		  // Prevent A Divide By Zero By
{
  height=1;		  // Making Height Equal One
}
glViewport(0,0,width,height);	  // Reset The Current Viewport
glMatrixMode(GL_PROJECTION);	  // Select The Projection Matrix
glLoadIdentity();		 // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);	   // Select The Modelview Matrix
glLoadIdentity();		 // Reset The Modelview Matrix
}

I found it here http://nehe.gamedev...._polygon/13002/
You can download the source code for multiple language's

#3 aqrit

aqrit

    Member

  • Members
  • 80 posts

Posted 14 April 2012 - 04:27 PM

thanks KEMiCZA

That spun me off in a positive direction ->

Here is the code that I just got working:
glMatrixMode(GL_PROJECTION);
glPushMatrix();

glLoadIdentity();
glOrtho(0, 640, 480, 0, -1, 1);

MovieToScreen_Original( color_index, width, height, rc, x=0, y=0, unknown );

glMatrixMode(GL_PROJECTION);
glPopMatrix();



#4 KEMiCZA

KEMiCZA

    Administrator

  • Administrators
  • 400 posts
  • LocationBelgium

Posted 14 April 2012 - 06:47 PM

I'm glad you got it working :)

#5 g3nuin3

g3nuin3

    Elite

  • Members
  • 261 posts

Posted 25 April 2012 - 08:04 AM

Quick question aqrit, does this distort the image at all?
-=Intelligence is my Bitch=-
Posted Image
<3 Micral for ths one ;)

#6 aqrit

aqrit

    Member

  • Members
  • 80 posts

Posted 25 April 2012 - 09:13 PM

Yes.
I don't have a great eye for such things. One could add fullscreen Anti-alaising easily.

If you change aspect ratios you get distrortions (say 640x480 stretched to 1440x900)
I don't have float support in my injector ( I push the floats by hand ) so I didn't want to do a Best-Fit calculation

If you wish to see for yourself:
here is the POC code for this project:

and as mentioned in that thread I added windowed mode and a stretchable window to a different game here (source code)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users