changed width and height to floats

This commit is contained in:
James Turk 2003-08-07 05:54:45 +00:00
parent e08d17a1f7
commit 246fc6e30a
2 changed files with 45 additions and 18 deletions

View File

@ -13,7 +13,7 @@
\brief Definition file for ZImage.
Definition file for ZImage, the OpenGL version of the ZImage class for ZEngine.
<br>$Id: ZE_ZImage.h,v 1.21 2003/08/02 01:18:45 cozman Exp $<br>
<br>$Id: ZE_ZImage.h,v 1.22 2003/08/07 05:54:45 cozman Exp $<br>
\author James Turk
**/
@ -51,9 +51,9 @@ class ZImage
//! Texture ID for OpenGL.
unsigned int rTexID;
//! Current draw width of Texture.
unsigned int rWidth;
GLfloat rWidth;
//! Current draw height of Texture.
unsigned int rHeight;
GLfloat rHeight;
#endif //GFX_BACKEND == OGL
public:
@ -271,7 +271,7 @@ class ZImage
\param width New width to stretch image to.
\param height New height to stretch image to.
**/
void Resize(unsigned int width, unsigned int height);
void Resize(float width, float height);
/*!
\brief OpenGL related bind call.
@ -301,6 +301,25 @@ class ZImage
**/
SDL_Surface *Surface() const;
#if (GFX_BACKEND == ZE_OGL)
/*!
\brief Get Width.
Get Current Width of Image.
\return Image Width.
**/
float Width() const;
/*!
\brief Get Height.
Get Current Height of Image.
\return Image Height.
**/
float Height() const;
#elif (GFX_BACKEND == ZE_SDL)
/*!
\brief Get Width.
@ -316,6 +335,7 @@ class ZImage
\return Image Height.
**/
int Height() const;
#endif //GFX_BACKEND
/*!
\brief Get Alpha component.

View File

@ -13,7 +13,7 @@
\brief Source file for ZImage.
Implementation of ZImage, the Image class for ZEngine.
<br>$Id: ZE_ZImage.cpp,v 1.39 2003/08/02 01:18:45 cozman Exp $<br>
<br>$Id: ZE_ZImage.cpp,v 1.40 2003/08/07 05:54:45 cozman Exp $<br>
\author James Turk
**/
@ -193,16 +193,7 @@ void ZImage::SetColorKey(Uint8 red, Uint8 green, Uint8 blue)
void ZImage::Draw(int x, int y) const
{
//source is same as float version, but uses glVertex2i
glColor4ub(255,255,255,rAlpha);
Bind();
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(rTexMinX,rTexMinY); glVertex2i(x,y);
glTexCoord2f(rTexMaxX,rTexMinY); glVertex2i(x+rWidth,y);
glTexCoord2f(rTexMinX,rTexMaxY); glVertex2i(x,y+rHeight);
glTexCoord2f(rTexMaxX,rTexMaxY); glVertex2i(x+rWidth,y+rHeight);
glEnd();
glColor4ub(255,255,255,255);
Draw(x,y);
}
void ZImage::Draw(float x, float y) const
@ -267,11 +258,11 @@ void ZImage::Flip(bool horizontal, bool vertical)
//stretching and resizing is very inexpensive, done via variables
void ZImage::Stretch(float xFactor, float yFactor)
{
rWidth = static_cast<unsigned int>(xFactor*rWidth);
rHeight = static_cast<unsigned int>(yFactor*rHeight);
rWidth = xFactor*rWidth;
rHeight = yFactor*rHeight;
}
void ZImage::Resize(unsigned int width, unsigned int height)
void ZImage::Resize(float width, float height)
{
rWidth = width;
rHeight = height;
@ -384,6 +375,20 @@ SDL_Surface* ZImage::Surface() const
return rImage;
}
#if (GFX_BACKEND == ZE_OGL)
float ZImage::Width() const
{
return rWidth;
}
float ZImage::Height() const
{
return rHeight;
}
#elif (GFX_BACKEND == ZE_SDL)
int ZImage::Width() const
{
return rImage->w;
@ -394,6 +399,8 @@ int ZImage::Height() const
return rImage->h;
}
#endif //GFX_BACKEND
Uint8 ZImage::Alpha() const
{
return rAlpha;