用户登录
用户注册

分享至

鼠标 opengl

  • 作者: 亦正亦邪26839443
  • 来源: 51数据库
  • 2020-10-01

无法显示鼠标的,你得自己画个。


//GLOBALS


//Z-Depth of the whole scene where the mouse is drawn


#define ZOOM -20.f


float mousePosition[2] = {0.0f,0.0f};


 


void GetMouseInfo() {


    static POINT lastMouse = {0,0};


    //Get current mouse position


    GetCursorPos(&lastMouse);


    //Set cursor position to some point so that the movement can be calculated later on


    SetCursorPos(320,240);


    //Calculate movement of the mouse with the above coords


    float moveX = float((320 - lastMouse.x))/100.0f;


    float moveY = float((240 - lastMouse.y))/100.0f;


    //Update mouse position


    mousePosition[0] -= moveX;


    mousePosition[1] += moveY;


}


 


void DrawMouseCursor() {


    //Will be transparent


    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);


    glEnable(GL_BLEND);


    glDisable(GL_DEPTH_TEST);


    //Draw the cursor at the current mouse pos


    glBegin(GL_TRIANGLES);


    glColor4f(0.75,0.75,0.75,0.75);


    glVertex3f(mousePosition[0],mousePosition[1],ZOOM);


    glVertex3f(mousePosition[0],mousePosition[1]-0.5f,ZOOM);


    glVertex3f(mousePosition[0]+0.5f,mousePosition[1],ZOOM);


    glEnd();


    //Alles wird wie vorher


    glDisable(GL_BLEND);


    glEnable(GL_DEPTH_TEST);


}

软件
前端设计
程序设计
Java相关