#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
using namespace std;
#define WIDTH 400
#define HEIGHT 300
#define N 10
float dens[N][N] = {};
void init(){
glClearColor(1.0, 1.0, 1.0,1.0);
//glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
//glOrtho(0, WIDTH, HEIGHT, 0, 0, 1);
//glMatrixMode(GL_MODELVIEW);
//gluOrtho2D(0.0,1.0,0.0,1.0);
//glDisable(GL_DEPTH_TEST);
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(3.0);
glBegin(GL_QUADS);
float h = 1.00/N;
for(int i=0; i<N; i++){
float x = 1.0*i/N;
for(int j=0; j<N; j++){
float y = 1.0*j/N;
glColor3f(1.0,0.0,0.0);
glVertex2f(x, y);
glColor3f(0.0,1.0,0.0);
glVertex2f(x+h, y);
glColor3f(0.0,0.0,1.0);
glVertex2f(x+h, y+h);
glColor3f(0.0,1.0,1.0);
glVertex2f(x, y+h);
}
}
glEnd();
glFlush();
}
int main(int argc, char* argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(WIDTH, HEIGHT);
glutInitWindowPosition(200, 100);
glutCreateWindow("Lucia OpenGL");
glClearColor(1.0, 1.0, 1.0, 0.0);
//glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
gluOrtho2D(0.0,1.0,0.0,1.0);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
#include <GL/glu.h>
#include <GL/glut.h>
using namespace std;
#define WIDTH 400
#define HEIGHT 300
#define N 10
float dens[N][N] = {};
void init(){
glClearColor(1.0, 1.0, 1.0,1.0);
//glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
//glOrtho(0, WIDTH, HEIGHT, 0, 0, 1);
//glMatrixMode(GL_MODELVIEW);
//gluOrtho2D(0.0,1.0,0.0,1.0);
//glDisable(GL_DEPTH_TEST);
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(3.0);
glBegin(GL_QUADS);
float h = 1.00/N;
for(int i=0; i<N; i++){
float x = 1.0*i/N;
for(int j=0; j<N; j++){
float y = 1.0*j/N;
glColor3f(1.0,0.0,0.0);
glVertex2f(x, y);
glColor3f(0.0,1.0,0.0);
glVertex2f(x+h, y);
glColor3f(0.0,0.0,1.0);
glVertex2f(x+h, y+h);
glColor3f(0.0,1.0,1.0);
glVertex2f(x, y+h);
}
}
glEnd();
glFlush();
}
int main(int argc, char* argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowSize(WIDTH, HEIGHT);
glutInitWindowPosition(200, 100);
glutCreateWindow("Lucia OpenGL");
glClearColor(1.0, 1.0, 1.0, 0.0);
//glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
gluOrtho2D(0.0,1.0,0.0,1.0);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
No comments:
Post a Comment