永发信息网

急!在vc++6.0上写个程序

答案:4  悬赏:80  手机版
解决时间 2021-05-07 19:13
关于三维物体 随便给个程序吧 类似星球转动之类的 能动的就行
最佳答案
超出我能力范围了
全部回答
#include <GL/glx.h> #include <GL/gl.h> #include <GL/glu.h> #include <X11/keysym.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <stdio.h> Display *dpy; Window glwin; static int attributes[] = {GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None}; #define SWAPBUFFERS glXSwapBuffers(dpy, glwin) #define BLACK_INDEX 0 #define RED_INDEX 1 #define GREEN_INDEX 2 #define BLUE_INDEX 4 #define WIDTH 300 #define HEIGHT 200 GLfloat latitude, longitude, latinc, longinc; GLdouble radius; #define GLOBE 1 #define CYLINDER 2 #define CONE 3 GLvoid resize(GLsizei, GLsizei); GLvoid initializeGL(GLsizei, GLsizei); GLvoid drawScene(GLvoid); void polarView( GLdouble, GLdouble, GLdouble, GLdouble); static Bool WaitForMapNotify(Display *d, XEvent *e, char *arg) { if ((e->type == MapNotify) && (e->xmap.window == (Window)arg)) { return GL_TRUE; } return GL_FALSE; } void main(int argc, char **argv) { XVisualInfo *vi; Colormap cmap; XSetWindowAttributes swa; GLXContext cx; XEvent event; GLboolean needRedraw = GL_FALSE, recalcModelView = GL_TRUE; int dummy; dpy = XOpenDisplay(NULL); if (dpy == NULL){ fprintf(stderr, "could not open display\n"); exit(1); } if(!glXQueryExtension(dpy, &dummy, &dummy)){ fprintf(stderr, "could not open display"); exit(1); } vi = glXChooseVisual(dpy, DefaultScreen(dpy), attributes); if (vi == NULL) { fprintf(stderr, "could not get visual\n"); exit(1); } cx = glXCreateContext(dpy, vi, None, GL_TRUE); if (cx == NULL) { fprintf(stderr, "could not create rendering context\n"); exit(1); } cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); swa.colormap = cmap; swa.border_pixel = 0; swa.event_mask = ExposureMask | KeyPressMask | StructureNotifyMask; glwin = XCreateWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, WIDTH, HEIGHT, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa); XSetStandardProperties(dpy, glwin, "xogl", "xogl", None, argv, argc, NULL); glXMakeCurrent(dpy, glwin, cx); XMapWindow(dpy, glwin); XIfEvent(dpy, &event, WaitForMapNotify, (char *)glwin); initializeGL(WIDTH, HEIGHT); resize(WIDTH, HEIGHT); while (1) { KeySym key; while (XPending(dpy)) { XNextEvent(dpy, &event); switch (event.type) { case KeyPress: XLookupString((XKeyEvent *)&event, NULL, 0, &key, NULL); switch (key) { case XK_Left: longinc += 0.5; break; case XK_Right: longinc -= 0.5; break; case XK_Up: latinc += 0.5; break; case XK_Down: latinc -= 0.5; break; } break; case ConfigureNotify: resize(event.xconfigure.width, event.xconfigure.height); break; } } drawScene(); } } GLvoid resize( GLsizei width, GLsizei height ) { GLfloat aspect; glViewport( 0, 0, width, height ); aspect = (GLfloat) width / height; glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45.0, aspect, 3.0, 7.0 ); glMatrixMode( GL_MODELVIEW ); } GLvoid createObjects() { GLUquadricObj *quadObj; glNewList(GLOBE, GL_COMPILE); quadObj = gluNewQuadric (); gluQuadricDrawStyle (quadObj, GLU_LINE); gluSphere (quadObj, 1.5, 16, 16); glEndList(); glNewList(CONE, GL_COMPILE); quadObj = gluNewQuadric (); gluQuadricDrawStyle (quadObj, GLU_FILL); gluQuadricNormals (quadObj, GLU_SMOOTH); gluCylinder(quadObj, 0.3, 0.0, 0.6, 15, 10); glEndList(); glNewList(CYLINDER, GL_COMPILE); glPushMatrix (); glRotatef ((GLfloat)90.0, (GLfloat)1.0, (GLfloat)0.0, (GLfloat)0.0); glTranslatef ((GLfloat)0.0, (GLfloat)0.0, (GLfloat)-1.0); quadObj = gluNewQuadric (); gluQuadricDrawStyle (quadObj, GLU_FILL); gluQuadricNormals (quadObj, GLU_SMOOTH); gluCylinder (quadObj, 0.3, 0.3, 0.6, 12, 2); glPopMatrix (); glEndList(); } GLvoid initializeGL(GLsizei width, GLsizei height) { GLfloat maxObjectSize, aspect; GLdouble near_plane, far_plane; glClearIndex( (GLfloat)BLACK_INDEX); glClearDepth( 1.0 ); glEnable(GL_DEPTH_TEST); glMatrixMode( GL_PROJECTION ); aspect = (GLfloat) width / height; gluPerspective( 45.0, aspect, 3.0, 7.0 ); glMatrixMode( GL_MODELVIEW ); near_plane = 3.0; far_plane = 7.0; maxObjectSize = 3.0F; radius = near_plane + maxObjectSize/2.0; latitude = 0.0F; longitude = 0.0F; latinc = 6.0F; longinc = 2.5F; createObjects(); } void polarView(GLdouble radius, GLdouble twist, GLdouble latitude, GLdouble longitude) { glTranslated(0.0, 0.0, -radius); glRotated(-twist, 0.0, 0.0, 1.0); glRotated(-latitude, 1.0, 0.0, 0.0); glRotated(longitude, 0.0, 0.0, 1.0); } GLvoid drawScene(GLvoid) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glPushMatrix(); latitude += latinc; longitude += longinc; polarView( radius, 0, latitude, longitude ); glIndexi(RED_INDEX); glCallList(CONE); glIndexi(BLUE_INDEX); glCallList(GLOBE); glIndexi(GREEN_INDEX); glPushMatrix(); glTranslatef(0.8F, -0.65F, 0.0F); glRotatef(30.0F, 1.0F, 0.5F, 1.0F); glCallList(CYLINDER); glPopMatrix(); glPopMatrix(); SWAPBUFFERS; }

我也没做过这种,你要的是VC图像处理编程的这种人才。

动画窗体行不?

  1、建立一个MFC AppWizard(exe)应用工程Animate。   在MFC AppWizard向导的第一步中选择“Single document”,再点击按键“Finish→OK”完成工程建立。   2、在CMainFrame::OnCreate函数中增加黑体加粗部分语句。   int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)   { ......   m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);   EnableDocking(CBRS_ALIGN_ANY);   DockControlBar(&&m_wndToolBar);   AnimateWindow(GetSafeHwnd(),1000,AW_CENTER);   return 0; }   3、使用MFC ClassWizard增加消息处理函数。   使用ClassWizard在CMainFrame类中增加WM_CLOSE消息处理函数,并增加以下语句:   void CMainFrame::OnClose()   {// TODO: Add your message handler code here and/or call default   AnimateWindow(GetSafeHwnd(),1000,AW_HIDE|AW_CENTER);   CFrameWnd::OnClose();}  

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
AU啥时候才能不卡不掉啊?
丝路英雄的联盟杯锁定了怎么办啊?我想解散
谁能告诉下情侣创意生活馆怎么样?(有开店的
帮忙配招:蘑菇袋鼠
现在QQ三国丈八蛇矛怎么赚钱快!(╯﹏╰)(
文稿与数据怎么关闭,苹果手机内存里的文稿与
1.25P的空调,一般开在24度,一小时耗电多少
哆咪烘焙地址在什么地方,想过去办事
谁知道[仙剑奇侠传3]的插曲,不要有歌词的,
为什么8月份的壹周立波秀跟5月份的一样啊
急!!!黑龙江农垦职业学院的寝室怎么样?都
3D第09304期开奖号码查询
高速费一公里多少钱,二类车高速多少钱一公里
"背叛情歌"的演唱者是谁?
老是失眠怎么回事
推荐资讯
代步用滑板选哪种
我的游戏不能和对手说话
征途118极的小号接不了银子任务
保险组名和口号大全,组名和口号大全
三都镇在哪里啊,我有事要去这个地方
“爱”怎样解释?
好烦 中午不知道烧黄瓜好还是烧土豆好?
QQ炫舞赤足黑羽衣服配那个翅膀好看
历史人物的生卒是怎么知道的
剑魂38连招
jeep搞活动
电脑前坐久了脖子酸痛怎么办?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?