Commits

Anonymous committed 51cdff8

Implemented rendering with client function stubs.

Comments (0)

Files changed (1)

pixmap_viz_client.cpp

     int height;
 };
 
+unsigned char* PixmapData;
+
 void client_initialize();
 client_info handshake(const char* const IP);
 //writes received data to next image into, Data can hold width*height*4 elements (RGBA)
 {
     cout << "Use the right mouse button to bring up the options menu.\n";
     cout << "Press Q to quit.\n";
+    //
+    client_initialize();
+    client_info Info = handshake("127.0.0.1");
+    application::ScreenWidth = Info.width;
+    application::ScreenHeight = Info.height;
+    PixmapData = new unsigned char [Info.width * Info.height * 4];
+    //
     glutInit(&argc,argv);
     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
     glutInitWindowSize(application::ScreenWidth, application::ScreenHeight);
 
 void display()
 {
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-    glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
-    glMatrixMode(GL_PROJECTION);
-    glPushMatrix();
-    glLoadIdentity();
-    glMatrixMode(GL_MODELVIEW);
-    glPushMatrix();
-    glLoadIdentity();
-    gluOrtho2D(0,1, -0, 1);
-    //gluOrtho2D(-LeftMargin, MaxX + LeftMargin, -BottomMargin, MaxY + BottomMargin);
-    //render_graph();
-    GLubyte Data[] = { 255, 0, 0, 1, 0, 255, 0, 255, 0, 0, 255, 255, 0, 255, 255, 255 };
-    glDisable(GL_DEPTH_TEST);
-    glRasterPos3f(0, 0, 0.0);
-    for(unsigned int i = 0; i < 100; ++i)
+    if(next_image(PixmapData))
     {
-        glDrawPixels(2, 2, GL_RGBA, GL_UNSIGNED_BYTE, Data);
+        using namespace application;
+        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
+        glMatrixMode(GL_MODELVIEW);
+        glLoadIdentity();
+        glMatrixMode(GL_PROJECTION);
+        glPushMatrix();
+        glLoadIdentity();
+        glMatrixMode(GL_MODELVIEW);
+        glPushMatrix();
+        glLoadIdentity();
+        gluOrtho2D(0,1, 0, 1);
+        //gluOrtho2D(-LeftMargin, MaxX + LeftMargin, -BottomMargin, MaxY + BottomMargin);
+        //render_graph();
+        GLubyte Data[] = { 255, 0, 0, 1, 0, 255, 0, 255, 0, 0, 255, 255, 0, 255, 255, 255 };
+        glDisable(GL_DEPTH_TEST);
+        glRasterPos3f(0, 0, 0.0);
+        for(unsigned int i = 0; i < 100; ++i)
+        {
+            glDrawPixels(ScreenWidth, ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, PixmapData);
+        }
+        assert(glGetError() == GL_NO_ERROR);
+        glutSwapBuffers();
+        glMatrixMode(GL_PROJECTION);
+        glPopMatrix();
+        glMatrixMode(GL_MODELVIEW);
+        glPopMatrix();
     }
-    assert(glGetError() == GL_NO_ERROR);
-    glutSwapBuffers();
+    else
+    {
+        close_connection();
+        client_deinitialize();
+        exit(0);
+    }
 }
 
 void client_initialize() {}
 //returns 1 on success, 0 on failure (failure, say, server closed.)
 int next_image(unsigned char* Data)
 {
+    int Index = 0;
+    for(unsigned int i = 0; i < 16*16; ++i)
+    {
+        Data[Index] = 128;
+        Data[Index + 1] = 192;
+        Data[Index + 2] = 64;
+        Data[Index + 3] = 255;
+        Index += 4;
+    }
     return 1;
 }
 void close_connection() {}