changed width and height to floats
This commit is contained in:
parent
e08d17a1f7
commit
246fc6e30a
@ -13,7 +13,7 @@
|
|||||||
\brief Definition file for ZImage.
|
\brief Definition file for ZImage.
|
||||||
|
|
||||||
Definition file for ZImage, the OpenGL version of the ZImage class for ZEngine.
|
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
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ class ZImage
|
|||||||
//! Texture ID for OpenGL.
|
//! Texture ID for OpenGL.
|
||||||
unsigned int rTexID;
|
unsigned int rTexID;
|
||||||
//! Current draw width of Texture.
|
//! Current draw width of Texture.
|
||||||
unsigned int rWidth;
|
GLfloat rWidth;
|
||||||
//! Current draw height of Texture.
|
//! Current draw height of Texture.
|
||||||
unsigned int rHeight;
|
GLfloat rHeight;
|
||||||
#endif //GFX_BACKEND == OGL
|
#endif //GFX_BACKEND == OGL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -271,7 +271,7 @@ class ZImage
|
|||||||
\param width New width to stretch image to.
|
\param width New width to stretch image to.
|
||||||
\param height New height 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.
|
\brief OpenGL related bind call.
|
||||||
@ -301,6 +301,25 @@ class ZImage
|
|||||||
**/
|
**/
|
||||||
SDL_Surface *Surface() const;
|
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.
|
\brief Get Width.
|
||||||
|
|
||||||
@ -316,6 +335,7 @@ class ZImage
|
|||||||
\return Image Height.
|
\return Image Height.
|
||||||
**/
|
**/
|
||||||
int Height() const;
|
int Height() const;
|
||||||
|
#endif //GFX_BACKEND
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Get Alpha component.
|
\brief Get Alpha component.
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
\brief Source file for ZImage.
|
\brief Source file for ZImage.
|
||||||
|
|
||||||
Implementation of ZImage, the Image class for ZEngine.
|
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
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -193,16 +193,7 @@ void ZImage::SetColorKey(Uint8 red, Uint8 green, Uint8 blue)
|
|||||||
|
|
||||||
void ZImage::Draw(int x, int y) const
|
void ZImage::Draw(int x, int y) const
|
||||||
{
|
{
|
||||||
//source is same as float version, but uses glVertex2i
|
Draw(x,y);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZImage::Draw(float x, float y) const
|
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
|
//stretching and resizing is very inexpensive, done via variables
|
||||||
void ZImage::Stretch(float xFactor, float yFactor)
|
void ZImage::Stretch(float xFactor, float yFactor)
|
||||||
{
|
{
|
||||||
rWidth = static_cast<unsigned int>(xFactor*rWidth);
|
rWidth = xFactor*rWidth;
|
||||||
rHeight = static_cast<unsigned int>(yFactor*rHeight);
|
rHeight = yFactor*rHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZImage::Resize(unsigned int width, unsigned int height)
|
void ZImage::Resize(float width, float height)
|
||||||
{
|
{
|
||||||
rWidth = width;
|
rWidth = width;
|
||||||
rHeight = height;
|
rHeight = height;
|
||||||
@ -384,6 +375,20 @@ SDL_Surface* ZImage::Surface() const
|
|||||||
return rImage;
|
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
|
int ZImage::Width() const
|
||||||
{
|
{
|
||||||
return rImage->w;
|
return rImage->w;
|
||||||
@ -394,6 +399,8 @@ int ZImage::Height() const
|
|||||||
return rImage->h;
|
return rImage->h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //GFX_BACKEND
|
||||||
|
|
||||||
Uint8 ZImage::Alpha() const
|
Uint8 ZImage::Alpha() const
|
||||||
{
|
{
|
||||||
return rAlpha;
|
return rAlpha;
|
||||||
|
Loading…
Reference in New Issue
Block a user