Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <GL/glut.h>
- void drawPixel(int x, int y, int r, int g, int b);
- void render(void);
- int main(int argc, char** argv){
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE);
- glutInitWindowSize(600, 400);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("Game");
- glutDisplayFunc(render);
- glutMainLoop();
- return 0;
- }
- void render(void) {
- glClearColor(0.12, 0.12, 0.13, 0.1);
- glClear(GL_COLOR_BUFFER_BIT);
- glFlush();
- int x = 0; int y = 0;
- /*
- do{
- drawPixel(x, y, 255, 35, 32);
- x++;
- if(x == 800) { x = 0; y++; glFlush();}
- }while(y != 640);
- */
- drawPixel(20, 400, 0, 255, 255);
- glFlush();
- }
- void drawPixel(int x, int y, int r, int g, int b) {
- float fr, fg, fb;
- fr = (float) r / 255.0;
- fg = (float) g / 255.0;
- fb = (float) b / 255.0;
- glColor3f(fr, fg, fb);
- glBegin(GL_POINTS);
- float xf = 0;
- float yf = 0;
- if(x < 400){
- xf = -0.999 + (float)x / 400;
- }else{
- xf = (float)x / 800;
- }
- if(y < 300){
- yf = 0.999 - (float) y / 300;
- }else{
- yf = - (float) y / 600;
- }
- if(x == 0){ xf = -0.99;}
- if(y == 0){ yf = 0.99;}
- glVertex2f(xf, yf);
- glEnd();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement