- Edit: Can someone please move this post to the OpenGL section of the forums if they think it is better off there.
Edited by Kevn, 13 October 2012 - 07:32 PM.
Posted 13 October 2012 - 05:21 PM
Edited by Kevn, 13 October 2012 - 07:32 PM.
Posted 13 October 2012 - 09:01 PM
struct RGBType {
float r;
float g;
float b;
};
RGBType *pixel_buffer = new RGBType[800 * 1200];
using namespace std;
int window_height = 800;
int window_width = 1200;
void setPixel(int x, int y)
{
pixel_buffer[800*y + x].r=0.5;
pixel_buffer[800*y + x].g=0.5;
pixel_buffer[800*y + x].b=0.5;
}
void display(void) {
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
lineBres(100, 100, 600, 600);
glDrawPixels(window_width, window_height, GL_RGB, GL_FLOAT, pixel_buffer);
glutSwapBuffers();
delete[] pixel_buffer;
glLoadIdentity();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitWindowSize (window_width, window_height);
glutInitWindowPosition (100,100);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow ("Project 1");
glViewport(0, 0, 800, 1200);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity( );
glMatrixMode(GL_PROJECTION);
glLoadIdentity( );
gluOrtho2D(0.0, 800.0, 0.0, 1200.0);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Edited by Kevn, 13 October 2012 - 09:53 PM.