#include <iostream>
#include <GL/glut.h>
using std::cout;
using std::endl;
float windowWidth=0;
float windowHeight=0;
float curX=0.0;
float curY=0.0;
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1.0,1.0,1.0);

glBegin(GL_POLYGON);
    glVertex3f(curX,curY,0.0);
    glVertex3f(curX+50,curY,0.0);
    glVertex3f(curX+50,curY+50,0.0);
    glVertex3f(curX,curY+50,0.0);
    glEnd();

//    glutSwapBuffers();
    glFlush();
}
void reshape(int w,int h)
{
    windowWidth=(float)w;
    windowHeight=(float)h;
    cout<<"cur width is :"<<w<<endl;
    cout<<"cur height is :"<<h<<endl;
    glViewport(0,0,(GLsizei)w,(GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0,(float)w,0.0,(float)h,-1.0,1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
void keyboard(unsigned char key, int x, int y)
{
    cout<<"you pressed the key is :"<<key<<endl;
    switch(key)
    {
    case 'w':
        curY+=20;
        break;
    case 's':
        curY-=20;
        break;
    case 'a':
        curX-=20;
        break;
    case 'd':
        curX+=20;
        break;
    default:
        break;
    }
    if(key=='q'||key=='Q')
        exit(0);
    glutPostRedisplay();
}
void motion(int x, int y)
{
    cout<<"mouse position :"<< "("<<x<<","<<y<<")"<<endl;
    curX=(float)x;
    curY=(float)(windowHeight-y);
    glutPostRedisplay();
}
void mouse(int button,int state,int x,int y)
{
    cout<<"come here yet"<<endl;
    switch(button)
    {
    case GLUT_LEFT_BUTTON:
        if(state==GLUT_DOWN)
            glutFullScreen();
        break;
    case GLUT_RIGHT_BUTTON:
        if(state==GLUT_DOWN)
        {
            glutInitWindowSize(800,600);
            glutInitWindowPosition(0.0,0.0);
        }
        break;
    default:
        break;
    }
    glutPostRedisplay();
}
void idler()
{
    cout<<"i am a idle"<<endl;
}
void init()
{
    glClearColor(0.0,0.0,0.0,0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-300.0,300.0,-300.0,300.0,-1.0,1.0);
}
int main(int argc,char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
    glutInitWindowSize(250,250);
    glutInitWindowPosition(0.0,0.0);
    glutCreateWindow("hello,gl Master");
//    glutFullScreen();
    init();
    glutDisplayFunc(display);
    glutReshapeFunc(reshape);
    glutKeyboardFunc(keyboard);
    glutMotionFunc(motion);
    glutMouseFunc(mouse);
    //  glutIdleFunc(idler);
    glutMainLoop();
    return 0;
}

coder的更多相关文章

  1. 面向组合子设计Coder

    面向组合子 面向组合子(Combanitor-Oriented),是最近帮我打开新世界大门的一种pattern.缘起haskell,又见monad与ParseC,终于ajoo前辈的几篇文章. 自去年9 ...

  2. Top Coder算法题目浏览器

    作者:Lucida 微博:@peng_gong 豆瓣:@figure9 原文链接:http://zh.lucida.me/blog/top-code-offline-browser/ 关于 左耳朵耗子 ...

  3. 高效coder,筹备开源框架toutou.escort.js

    背景:JavaScript在工作中运用的非常广泛,作为一门弱类型语言,在使用JavaScript的时候,很多事情需要coder manual的去完成,这无疑增加了coder的工作量. 扩展:在这样的背 ...

  4. 新时代的coder如何成为专业程序员

    在移动互联网"泛滥"的今天,越来越多非专业(这里的非专业指的是非计算机专业毕业的程序员)程序员加入到了IT行业中来了,可能是因为移动互联网的火爆导致程序员容易就业而且工资很高,可能 ...

  5. java 练手 谁是最好的Coder

    Problem A 谁是最好的Coder 时间限制:1000 ms  |  内存限制:65535 KB   描述 计科班有很多Coder,帅帅想知道自己是不是综合实力最强的coder. 帅帅喜欢帅,所 ...

  6. java coder的水平

    写java写了也12年了,不决的自己是高手,但是也体会了一些变化.总的来说,Java可以分成几个层次: 首先是需求理解层次,这个层次的coder能理解需求,把需求转化成代码: 第二个层次是单测,能够对 ...

  7. nyist 596 谁是最好的Coder

    http://acm.nyist.net/JudgeOnline/problem.php?pid=596 谁是最好的Coder 时间限制:1000 ms  |  内存限制:65535 KB 难度:0 ...

  8. HDU4288:Coder(线段树单点更新版 && 暴力版)

    Problem Description In mathematics and computer science, an algorithm describes a set of procedures ...

  9. CodeForces 384A Coder

    Coder Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  10. HM中再增加一路自己的entropy coder

    compressSlice 中一开始的entropy coder 设置: // set entropy coder if( m_pcCfg->getUseSBACRD() ) { m_pcSba ...

随机推荐

  1. android设备连接不上电脑的解决方法

    先检查手机usb调试是否开启,已经开启还是连不上按照以下步骤操作: 1. 打开cmd,输入adb devices  查看设备是否连接 2.服务未启动,先杀掉服务:adb kill-server 3.启 ...

  2. MiniCodeEditor:只有168字节的在线Html/CSS/JavaScript编辑器

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:MiniCodeEditor:只有168字节的在线Html/CSS/JavaScript编辑器.

  3. WebBindingInitializer学习

    今天在看开源代码的时候遇到了这个接口,于是查阅了下相关的资料 Spring web mvc学习笔记 http://www.cnblogs.com/crazy-fox/archive/2012/02/1 ...

  4. C# 动态创建出来的窗体间的通讯 delegate1

    附件 http://files.cnblogs.com/xe2011/CSharp_WindowsForms_delegate01.rar 需要每个窗体是独立存在,禁止相与引用窗体 这样干净并且可以反 ...

  5. CCProgressTimer用法

    bool HelloWorld::init(){ if ( !CCLayerColor::initWithColor(ccc4(255, 255, 2555, 255))){ return false ...

  6. static inner class 什么时候被加载

    一直认为在加载outer class 的同时也会加载inner class 并且完成静态变量和代码块的初始化,今天在维基百科上面看到 “The static class definitionLazyH ...

  7. JavaScript 应用开发 #2:视图与模板

    在用 Backbone 开发的 JavaScript 应用里面,除了模型与集合以外,另一个重要的部分就是视图,英文是 View .在视图里面,我们可以去监听在页面上发生的事件,还有与视图相关的模型和集 ...

  8. iOS UIKit:TableView之表格创建(1)

    Table View是UITableView类的实例对象,其是使用节(section)来描述信息的一种滚动列表.但与普通的表格不同,tableView只有一行,且只能在垂直方向进行滚动.tableVi ...

  9. Sae配置Java数据库连接

    Sae配置Java数据库连接 Sae在Java中配置mysql数据库 >>>>>>>>>>>>>>>>& ...

  10. 1. 连接字符串的创建 - Lazy.Framework从零开始设计自己的ORM架构

    开发初衷 注册了博客园已经有几个月了,却从来都没有上来过,本人大概从2010年开始就开始做.NET 方向的开发. 这个是我在博客园发布的第一个帖子. 主要就是说说最近在写的一个ORM架构. 本人接触的 ...