|
|
发表于 2004-12-10 23:21:00
|
显示全部楼层
Re:[ OpenGL ] Stupid Question, but need help
挺好的啊,没错啊,
//-----------My Test File-------------//
#include <gl\glut.h>
#include <gl\glu.h>
#include <iostream>
using namespace std;
//************************Global variable**********************//
void init();
UCHAR pTest[32];
void changeSize(int w1, int h1)
{
// Reset the coordinate system before modifying
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set the viewport to be the entire window
glViewport(0, 0, 1024, 768);
// Set the clipping volume
glOrtho( 0, 1024, 0, 768, - 1.0f, 256.0f );
// setting the camera now
glMatrixMode(GL_MODELVIEW);
}
//**************************Display Func*********************************//
void renderScene(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
// Loop Start ( Have Cleared COLOR_BUFFER & DEPTH_BUFFER )
// ( Have Loaded Identity for ModelView Matrix Stack )
glColor3f( 1,1,1 );
for( UINT aa = 0; aa < 1000; aa ++)
{
glRasterPos2i( rand() % 600, rand() % 600 );
glBitmap( 8, 16, 0, 0, 0, 0, pTest );
}
glutSwapBuffers();
}
//*******************************init func*********************************//
void init()
{
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
memset( pTest, 0xff, sizeof( pTest ) );
glDisable(GL_LIGHTING);
glutDisplayFunc(renderScene);
glutReshapeFunc(changeSize);
glClearColor(0,0,0,0);
}
//********************************main**************************************//
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0,0);
glutInitWindowSize(1024,768);
glutCreateWindow("My sample");
//alutInit(NULL, 0);
init();
glutMainLoop();
return 0 ;
}
|
|