ZImage miniscule changes
This commit is contained in:
parent
73c69b64c7
commit
59c07de8d7
@ -1,5 +1,5 @@
|
|||||||
ZEngine Version Log for Version 0.8.4
|
ZEngine Version Log for Version 0.8.5
|
||||||
$Id: changelog.txt,v 1.43 2003/08/31 22:15:00 cozman Exp $
|
$Id: changelog.txt,v 1.44 2003/09/05 19:44:13 cozman Exp $
|
||||||
|
|
||||||
Changes are marked with symbols that describe them:
|
Changes are marked with symbols that describe them:
|
||||||
! is code that breaks backwards compatibility (used after 0.8.0-rc1, previous versions broke compatibility)
|
! is code that breaks backwards compatibility (used after 0.8.0-rc1, previous versions broke compatibility)
|
||||||
@ -9,9 +9,11 @@ Changes are marked with symbols that describe them:
|
|||||||
# general changes
|
# general changes
|
||||||
|
|
||||||
0.8.5
|
0.8.5
|
||||||
+ Addition of limited SDL graphics backend.
|
+ Addition of DrawClipped and DrawClipped example in ZImageTest
|
||||||
|
+ New limited SDL graphics backend for platforms without OpenGL.
|
||||||
- Removal of VC6 project files and official support.
|
- Removal of VC6 project files and official support.
|
||||||
- Removal of SDL_net support.
|
- Removal of SDL_net support.
|
||||||
|
# Tiny optimizations within newer ZImage code.
|
||||||
# Changed ZImage stretching to floating-point.
|
# Changed ZImage stretching to floating-point.
|
||||||
# New linux build system (by Atani).
|
# New linux build system (by Atani).
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
\brief Define file for ZEngine where all #define statements to control compilation options are placed.
|
\brief Define file for ZEngine where all #define statements to control compilation options are placed.
|
||||||
|
|
||||||
Definition file, holds #define statements describing optional features of ZEngine.
|
Definition file, holds #define statements describing optional features of ZEngine.
|
||||||
<br>$Id: ZE_Defines.h,v 1.22 2003/08/08 04:24:42 cozman Exp $<br>
|
<br>$Id: ZE_Defines.h,v 1.23 2003/09/05 19:44:13 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
//Defines- undefine any of these if you dont have the indicated SDL extension//
|
//Defines- undefine any of these if you dont have the indicated SDL extension//
|
||||||
|
|
||||||
|
|
||||||
//! OpenGL 2D Rendering Target.
|
//! OpenGL 2D Rendering Target.
|
||||||
#define ZE_OGL (1)
|
#define ZE_OGL (1)
|
||||||
//! SDL Rendering Target.
|
//! SDL Rendering Target.
|
||||||
|
@ -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.24 2003/09/01 03:30:39 cozman Exp $<br>
|
<br>$Id: ZE_ZImage.h,v 1.25 2003/09/05 19:44:13 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -216,9 +216,11 @@ class ZImage
|
|||||||
void Draw(int x, int y) const;
|
void Draw(int x, int y) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Draw Clipped Image to screen.
|
\brief Draw Image, clipped within a given rectangle to the screen.
|
||||||
|
|
||||||
Image is drawn such that only portions of image which fall within a certain area appear.
|
Image is drawn such that only portions of image which fall within a certain area appear. This clipping rectangle
|
||||||
|
can be used for areas of the screen which are separated from others such as a splitscreen mode in a game or a
|
||||||
|
map on a HUD.
|
||||||
\since 0.8.5
|
\since 0.8.5
|
||||||
\param x X coord to draw Image to.
|
\param x X coord to draw Image to.
|
||||||
\param y Y coord to draw Image to.
|
\param y Y coord to draw Image to.
|
||||||
@ -259,9 +261,11 @@ class ZImage
|
|||||||
void DrawRotated(float x, float y, float angle) const;
|
void DrawRotated(float x, float y, float angle) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Draw Clipped Image to screen.
|
\brief Draw Image, clipped within a given rectangle to the screen.
|
||||||
|
|
||||||
Image is drawn such that only portions of image which fall within a certain area appear.
|
Image is drawn such that only portions of image which fall within a certain area appear. This clipping rectangle
|
||||||
|
can be used for areas of the screen which are separated from others such as a splitscreen mode in a game or a
|
||||||
|
map on a HUD.
|
||||||
\since 0.8.5
|
\since 0.8.5
|
||||||
\param x X coord to draw Image to.
|
\param x X coord to draw Image to.
|
||||||
\param y Y coord to draw Image to.
|
\param y Y coord to draw Image to.
|
||||||
|
@ -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.44 2003/09/01 06:01:34 cozman Exp $<br>
|
<br>$Id: ZE_ZImage.cpp,v 1.45 2003/09/05 19:44:13 cozman Exp $<br>
|
||||||
\author James Turk
|
\author James Turk
|
||||||
**/
|
**/
|
||||||
|
|
||||||
@ -244,10 +244,7 @@ void ZImage::DrawRotated(float x, float y, float angle) const
|
|||||||
|
|
||||||
void ZImage::DrawClipped(float x, float y, ZRect clipRect) const
|
void ZImage::DrawClipped(float x, float y, ZRect clipRect) const
|
||||||
{
|
{
|
||||||
ZRect imgRect(x,y,rWidth,rHeight),inRect;
|
ZRect imgRect(x,y,rWidth,rHeight);
|
||||||
float xDiff,yDiff,nx,ny,nw,nh;
|
|
||||||
xDiff = rTexMaxX - rTexMinX;
|
|
||||||
yDiff = rTexMaxY - rTexMinY;
|
|
||||||
|
|
||||||
if(clipRect.Contains(imgRect))
|
if(clipRect.Contains(imgRect))
|
||||||
{
|
{
|
||||||
@ -255,20 +252,30 @@ void ZImage::DrawClipped(float x, float y, ZRect clipRect) const
|
|||||||
}
|
}
|
||||||
else if(clipRect.Intersects(imgRect))
|
else if(clipRect.Intersects(imgRect))
|
||||||
{
|
{
|
||||||
inRect = clipRect.Intersection(imgRect);
|
//This is some pretty complex code, it is broken down in 4 steps.
|
||||||
|
|
||||||
nx = rTexMinX + (inRect.X()-imgRect.X())/imgRect.Width()*xDiff;
|
//Step 1: The intersection rectangle (inRect) is compared to the image rectangle and the overlapping area is found.
|
||||||
ny = rTexMinY + (inRect.Y()-imgRect.Y())/imgRect.Height()*yDiff;
|
ZRect inRect = clipRect.Intersection(imgRect);
|
||||||
nw = nx + (inRect.Width()/imgRect.Width())*xDiff;
|
|
||||||
nh = ny + (inRect.Height()/imgRect.Height())*yDiff;
|
|
||||||
|
|
||||||
glColor4ub(255,255,255,rAlpha); //sets the color correctly
|
//Step 2: The portion of the image that needs to be drawn is being mapped to triangle strips the same size as the intersection
|
||||||
|
// of the clipping and image rectangles and then transformed to texture coordinates via xScale and yScale.
|
||||||
|
// (double is used for needed precision when dealing with the scaling)
|
||||||
|
double xScale = (rTexMaxX - rTexMinX)*rWidth; //texCoordWidth/imgWidth
|
||||||
|
double yScale = (rTexMaxY - rTexMinY)*rHeight; //texCoordHeight/imgHeight
|
||||||
|
double nx = rTexMinX + (inRect.X()-x)/xScale; //cut off left side
|
||||||
|
double ny = rTexMinY + (inRect.Y()-y)/yScale; //cut off top
|
||||||
|
double nw = nx + inRect.Width()/xScale; //cut off right side
|
||||||
|
double nh = ny + inRect.Height()/yScale; //cut off bottom
|
||||||
|
|
||||||
|
glColor4ub(255,255,255,rAlpha);
|
||||||
Bind();
|
Bind();
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
glTexCoord2f(nx,ny); glVertex2f(inRect.Left(),inRect.Top());
|
//Step 3: The texture coords are modified to only specify the portion of the texture which falls within the clipping rect.
|
||||||
glTexCoord2f(nw,ny); glVertex2f(inRect.Right(),inRect.Top());
|
//Step 4: The vertices are changed to the sides of the clipping rectangle in glVertex2f.
|
||||||
glTexCoord2f(nx,nh); glVertex2f(inRect.Left(),inRect.Bottom());
|
glTexCoord2d(nx,ny); glVertex2f(inRect.Left(),inRect.Top());
|
||||||
glTexCoord2f(nw,nh); glVertex2f(inRect.Right(),inRect.Bottom());
|
glTexCoord2d(nw,ny); glVertex2f(inRect.Right(),inRect.Top());
|
||||||
|
glTexCoord2d(nx,nh); glVertex2f(inRect.Left(),inRect.Bottom());
|
||||||
|
glTexCoord2d(nw,nh); glVertex2f(inRect.Right(),inRect.Bottom());
|
||||||
glEnd();
|
glEnd();
|
||||||
glColor4ub(255,255,255,255); //be responsible, return to standard color state
|
glColor4ub(255,255,255,255); //be responsible, return to standard color state
|
||||||
}
|
}
|
||||||
@ -280,21 +287,11 @@ void ZImage::DrawClipped(float x, float y, ZRect clipRect) const
|
|||||||
|
|
||||||
void ZImage::Flip(bool horizontal, bool vertical)
|
void ZImage::Flip(bool horizontal, bool vertical)
|
||||||
{
|
{
|
||||||
GLfloat temp;
|
|
||||||
//all that a flip does is invert the Min/Max coordinates
|
//all that a flip does is invert the Min/Max coordinates
|
||||||
if(horizontal)
|
if(horizontal)
|
||||||
{
|
std::swap(rTexMinX,rTexMaxX);
|
||||||
temp = rTexMinX;
|
|
||||||
rTexMinX = rTexMaxX;
|
|
||||||
rTexMaxX = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(vertical)
|
if(vertical)
|
||||||
{
|
std::swap(rTexMinY,rTexMaxY);
|
||||||
temp = rTexMinY;
|
|
||||||
rTexMinY = rTexMaxY;
|
|
||||||
rTexMaxY = temp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//stretching and resizing is very inexpensive, done via variables
|
//stretching and resizing is very inexpensive, done via variables
|
||||||
|
@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
|
|||||||
and the home of this Library is http://www.zengine.sourceforge.net
|
and the home of this Library is http://www.zengine.sourceforge.net
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
/*$Id: ZImageTest.cpp,v 1.22 2003/09/01 06:01:06 cozman Exp $*/
|
/*$Id: ZImageTest.cpp,v 1.23 2003/09/05 19:44:13 cozman Exp $*/
|
||||||
|
|
||||||
#include <ZEngine.h>
|
#include <ZEngine.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -55,12 +55,13 @@ void Test()
|
|||||||
image1.Attach(temp); //this attaches the surface into itself
|
image1.Attach(temp); //this attaches the surface into itself
|
||||||
image2.Open("data/test01.bmp");
|
image2.Open("data/test01.bmp");
|
||||||
image3.OpenFromImage(image2.Surface(),5,5,20,20);
|
image3.OpenFromImage(image2.Surface(),5,5,20,20);
|
||||||
image4.Open("data/rainbow.bmp");
|
image4.Open("data/test02.bmp");
|
||||||
temp = NULL; //and temp will now be controlled and freed by image1
|
temp = NULL; //and temp will now be controlled and freed by image1
|
||||||
image1.SetColorKey(255,0,255);
|
image1.SetColorKey(255,0,255);
|
||||||
image2.SetColorKey(255,0,255);
|
image2.SetColorKey(255,0,255);
|
||||||
#if (GFX_BACKEND == ZE_OGL)
|
#if (GFX_BACKEND == ZE_OGL)
|
||||||
image4.Resize(400,300);
|
image4.Resize(400,300);
|
||||||
|
image4.Flip(true,false);
|
||||||
#endif
|
#endif
|
||||||
font.DrawShadedText("ZImage Test.",textImage);
|
font.DrawShadedText("ZImage Test.",textImage);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user