当前位置: 代码迷 >> C语言 >> 怎样用C语言编图形 thank you
  详细解决方案

怎样用C语言编图形 thank you

热度:392   发布时间:2008-05-30 19:00:18.0
怎样用C语言编图形 thank you
提示: 作者被禁止或删除 内容自动屏蔽
2008-05-30 11:00:18
卧龙孔明

等 级:贵宾
威 望:59
帖 子:3988
专家分:684
注 册:2006-10-13
  得分:0 
这根本不贴谱~~~于数组没关系
----------------解决方案--------------------------------------------------------
最近我在看opengl
给你个代码吧:
#include <windows.h>
#define GLUT_DISABLE_ATEXIT_HACK
#include <math.h>
#include <gl/gl.h>
#include <gl/glut.h>
void myInit()
{
  glClearColor(1.0,1.0,1.0,0.0);
  glColor3f(0.0f,0.0f,0.0f);
  glPointSize(4.0);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluOrtho2D(0.0,640.0,0.0,480.0);
}

void myDisplay()
{
  glClear(GL_COLOR_BUFFER_BIT);
  glFlush();
}
void myMouse(int button, int state, int x, int y)
{
  if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
  {
    glRecti(x,480-y,x+10,480-y+10);
  }else if(button == GLUT_RIGHT_BUTTON && state == GLUT_DOWN){
    glClear(GL_COLOR_BUFFER_BIT);
  }
  glFlush();
}
void myMovedMouse(int mouseX, int mouseY)
{
  glRecti(mouseX,480-mouseY,mouseX+1,480-mouseY+1);
  glFlush();
}
int main(int argc, char ** argv)
{
  glutInit(&argc,argv);
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
  glutInitWindowSize(640,480);
  glutCreateWindow("my first attempt");
  glutDisplayFunc(myDisplay);
  glutMouseFunc(myMouse);
  glutMotionFunc(myMovedMouse);
  myInit();
  glutMainLoop();
}
----------------解决方案--------------------------------------------------------
Turbo C下用graphics.h
----------------解决方案--------------------------------------------------------
顶4楼的
----------------解决方案--------------------------------------------------------
  相关解决方案