// G_Window.cpp: implementation of the G_Window class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "G_Window.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
G_Window::G_Window()
{
}
G_Window::~G_Window()
{
}
GLboolean G_Window::glInit(){
glClearColor(1.0f,1.0f,1.0f,1.0);
glColor3f(1.0f,0.0f,0.0f);
return true;
}
GLvoid G_Window::gtInitCallBacks(){
glutDisplayFunc(gtDraw);
glutKeyboardFunc(gtKeyboard);
glutReshapeFunc(gtReshape);
glutMouseFunc(gtMouse);
glutIdleFunc(gtDraw);
}
GLvoid G_Window::gtDraw(){
glClear(GL_COLOR_BUFFER_BIT);
glPointSize(4.0);
glBegin(GL_POINTS);
glVertex2f(0,0);
glEnd();
glutSwapBuffers();
glFlush();
}
GLvoid G_Window::gtKeyboard(unsigned char key,GLint x,GLint y){
switch(key){
case 27:
PostQuitMessage(0);
break;
default:break;
}
}
GLvoid G_Window::gtReshape(GLint w,GLint h){
if(w<1)
w=1;
if(h<1)
h=1;
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// gluOrtho2D(0,w,0,h);
}
GLvoid G_Window::gtMouse(GLint button,GLint state,GLint x,GLint y){
switch(button){
case GLUT_LEFT_BUTTON:
if(state==GLUT_DOWN)
{//Add your code hear
MessageBox(NULL,"Left has pressed","Message",MB_OK);
}
break;
case GLUT_RIGHT_BUTTON:
if(state==GLUT_DOWN)
{//Add your code hear
MessageBox(NULL,"Right has pressed","Message",MB_OK);
}
break;
case GLUT_MIDDLE_BUTTON:
if(state==GLUT_DOWN)
{//Add your code hear
MessageBox(NULL,"Middle has pressed","Message",MB_OK);
}
break;
}
}
GLUT C++开发框架
需积分: 10 56 浏览量
2009-04-10
22:41:00
上传
评论
收藏 4KB RAR 举报
billow36
- 粉丝: 0
- 资源: 23