static void set_projection() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); int l = 0; int r = win_width(); int b = 0; int t = win_height(); gluOrtho2D(l, r, b, t); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
int main(int argc, char* argv[]) { win_new(); glfwSetWindowTitle("font_perf"); // font_set_color(1, 1, 1, 0); perf_init(); // main loop glClearColor(0.3f, 0.3f, 0.3f, 1.0f); while(1) { perf_mark_beg("glClear"); glClear(GL_COLOR_BUFFER_BIT); perf_mark_end("glClear"); perf_mark_beg("ortho"); glMatrixMode(GL_PROJECTION); glLoadIdentity(); int l = 0; int r = win_width(); int b = 0; int t = win_height(); gluOrtho2D(l, r, b, t); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); perf_mark_end("ortho"); // draw bitmap letter // perf_mark_beg("draw_letter"); // int i; // for(i = 0; i < 50; ++i) { draw_letter(); // } // perf_mark_end("draw_letter"); // font_draw(100, 100, "bitchin camaro!"); perf_mark_beg("swap"); glfwSwapBuffers(); perf_mark_end("swap"); if(!glfwGetWindowParam(GLFW_OPENED)) break; // fps_inc_frames_drawn(); perf_report(); } perf_terminate(); glfwTerminate(); return 0; }
LRESULT CALLBACK SpltNs_WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static int oldy; static int x; static int line_width; static int min_top; static int max_bottom; POINT pt; HDC hdc; RECT rect; HWND hp = GetParent(hwnd); switch (message) { case WM_CREATE: return 0 ; case WM_LBUTTONDOWN: SetCapture(hwnd); ns_sizing = 1; line_width = win_width(hwnd); x = win_left(hwnd);; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetWindowRect(hp,&rect); min_top= win_top(hp)+ MIN_SPLT_SPACE; max_bottom = win_bottom(hp) - MIN_SPLT_SPACE; //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; ClientToScreen(hwnd,&pt); //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.y < min_top) pt.y = min_top; if(pt.y > max_bottom) { pt.y = max_bottom; } hdc = GetDC(NULL); DrawXorBar(hdc, x, pt.y-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); oldy = pt.y; break; case WM_LBUTTONUP: ReleaseCapture(); pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); GetClientRect(hp,&rect); //GetClientRect(hwnd,&splt_rect); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; hdc = GetDC(NULL); DrawXorBar(hdc, x, oldy-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); ns_sizing = 0; pt.y = oldy; ScreenToClient(hp,&pt); send_splitter_y(hp, pt.y); break; case WM_MOUSEMOVE: if(0==ns_sizing) break; pt.x = (short)LOWORD(lParam); // horizontal position of cursor pt.y = (short)HIWORD(lParam); //GetClientRect(hwnd_frame,&rect); //GetClientRect(hwnd,&splt_rect); //SCreenToClient(rect); ClientToScreen(hwnd,&pt); //GetWindowRect(hwnd_frame, &rect_frame_scr); //client_0_0.x = 0; //client_0_0.y=0; //ClientToScreen(hwnd_frame,&client_0_0); //client_0_0.y-= rect_frame_scr.top; //client_0_0.x-= rect_frame_scr.left; //convert the mouse coordinates relative to the top-left of //the window //ScreenToClient(hwnd_frame,&pt); if(pt.y < min_top) pt.y = min_top; if(pt.y > max_bottom) { pt.y = max_bottom; } if(pt.y != oldy && wParam & MK_LBUTTON) { hdc = GetDC(NULL); DrawXorBar(hdc, x, oldy-SPLT_WIDTH/2, line_width, SPLT_WIDTH); DrawXorBar(hdc, x, pt.y-SPLT_WIDTH/2, line_width, SPLT_WIDTH); ReleaseDC(NULL, hdc); oldy = pt.y; } break; } return DefWindowProc (hwnd, message, wParam, lParam) ; }