int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { LDFS_Init(WndProc); LDFS_CreateWindow("test", 1, LDFS_AUTO, LDFS_AUTO); while(1) { if(LDFS_Update()) { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(angle, 0.0f, 0.0f, 1.0f); glBegin(GL_TRIANGLES); glColor3f(1.0f, 0.0f, 0.0f); glVertex2f(0.0f, 1.0f); glColor3f(0.0f, 1.0f, 0.0f); glVertex2f(0.87f, -0.5f); glColor3f(0.0f, 0.0f, 1.0f); glVertex2f(-0.87f, -0.5f); glEnd(); glPopMatrix(); if(holdingSpace) angle += 0.5f; LDFS_SwapBuffers(); } else { LDFS_DestroyWindow(); return 0; } } }
void drawFramebuffer(void) { // Should render to a texture instead of obsolete glDrawPixels //framebuffer[x + y * 160].r = 255; //framebuffer[x + y * 160].g = 255; //framebuffer[x + y * 160].b = 255; glClear(GL_COLOR_BUFFER_BIT); glRasterPos2f(-1, 1); glPixelZoom(1, -1); glDrawPixels(160, 144, GL_RGB, GL_UNSIGNED_BYTE, framebuffer); #ifdef WIN LDFS_SwapBuffers(); #ifndef DEBUG_SPEED LDFS_MaintainFramerate(); #endif #endif #ifdef LIN glXSwapBuffers(dpy, win); #ifndef DEBUG_SPEED static struct timespec frameStart; struct timespec frameEnd; long mtime, seconds, useconds; clock_gettime(CLOCK_MONOTONIC, &frameEnd); seconds = frameEnd.tv_sec - frameStart.tv_sec; useconds = frameEnd.tv_nsec - frameStart.tv_nsec; mtime = (seconds * 1000 + useconds / (1000.0 * 1000.0)); if(mtime < 1.0 / 60.0) Sleep(1 / 60.0 - mtime); clock_gettime(CLOCK_MONOTONIC, &frameStart); #endif #endif }