#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
void myinit(void);
void triangle(void);
void SourceImage(void);
void CALLBACK display(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
void myinit (void)
{
glClear (GL_COLOR_BUFFER_BIT);
//glPixelZoom(0.5,0.5);
//
}
void triangle(void)
{
glBegin (GL_TRIANGLES);
glColor3f (0.0, 1.0, 0.0);
glVertex2f (2.0, 3.0);
glColor3f(0.0,0.0,1.0);
glVertex2f (12.0, 3.0);
glColor3f(1.0,0.0,0.0);
glVertex2f (7.0, 12.0);
glEnd ();
}
void SourceImage(void)
{
glPushMatrix();
glLoadIdentity();
glTranslatef(4.0,8.0,0.0);
glScalef(0.5,0.5,0.5);
triangle ();
glPopMatrix();
}
void CALLBACK display(void)
{
int i;
/* 绘制原始图像 */
SourceImage();
/* 拷贝图像 */
for(i=0;i<5;i++)
{
//glPixelZoom((i+1)/5.,(i+1)/5.);
glRasterPos2i( 1+i*2,i);
glCopyPixels(160,310,170,160,GL_COLOR);
}
glFlush ();
}
void CALLBACK myReshape(GLsizei w, GLsizei h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
gluOrtho2D (0.0, 15.0, 0.0, 15.0 * (GLfloat) h/(GLfloat) w);
else
gluOrtho2D (0.0, 15.0 * (GLfloat) w/(GLfloat) h, 0.0, 15.0);
glMatrixMode(GL_MODELVIEW);
}
void main(void)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGBA);
auxInitPosition (0, 0, 500, 500);
auxInitWindow ("Pixel Processing");
myinit();
auxReshapeFunc (myReshape);
auxMainLoop(display);
}
评论0