极品飞车148无法进入出现DirectX function"CreatePixelShader for(null)"failed with E-INVALIDARG

& 按照安装说明更新了显卡驱动 但是进不去游戏了 截图如下 ...
查看: 3038|回复: 6
UID7886088主题阅读权限10帖子精华0积分2金钱14 荣誉0 人气0 在线时间0 小时评议0
Lv.1游侠新人, 积分 2, 距离下一级还需 3 积分
帖子精华0积分2金钱14 荣誉0 人气0 评议0
传不了图 我打字
DirectX Error
DirectX function &CreatePixelShader for (null)& failed with E_INVALIDARG (&An invalid parameter was passed to the returning function.&). GPU:&Intel(R) HD Graphics 3000&, Driver: Unknown
怎么解决啊
(,,???,,)游侠资深版主『动作游戏区』水晶圣斗士
UID6761466主题阅读权限150帖子精华0积分9277金钱57 荣誉118 人气3081 在线时间18298 小时评议15
帖子精华0积分9277金钱57 荣誉118 人气3081 评议15
显示使用HD3000的CPU内置集显,切换到独显试试
咱最喜欢吃虾米,因为营养又健康咱最喜欢撸侠盗,因为自由且暴力咱最喜欢玩竞速游戏,因为激情超无限咱更喜欢动作类游戏,因为揍人不要钱
UID7886088主题阅读权限10帖子精华0积分2金钱14 荣誉0 人气0 在线时间0 小时评议0
Lv.1游侠新人, 积分 2, 距离下一级还需 3 积分
帖子精华0积分2金钱14 荣誉0 人气0 评议0
鬼之魇 发表于
显示使用HD3000的CPU内置集显,切换到独显试试
切换了 还是提示那个
UID1520650主题阅读权限40帖子精华0积分728金钱7843 荣誉1 人气2 在线时间4391 小时评议0
Lv.4游侠高级会员, 积分 728, 距离下一级还需 272 积分
帖子精华0积分728金钱7843 荣誉1 人气2 评议0
集显不是用来玩游戏的
UID7886088主题阅读权限10帖子精华0积分2金钱14 荣誉0 人气0 在线时间0 小时评议0
Lv.1游侠新人, 积分 2, 距离下一级还需 3 积分
帖子精华0积分2金钱14 荣誉0 人气0 评议0
smallbabylee 发表于
集显不是用来玩游戏的
想尝试一下。。
之前切换独显就进去了 提示是的尾端是 at least 512M
然后我更新了显卡驱动 结果就进不去了 就是这个样子
geforce 610M 确实地段 只是想尝试xiaonei
游侠剑阁工作组组长游侠游戏库大师
UID1069591主题阅读权限70帖子精华13积分43395金钱83703 荣誉559 人气630 在线时间18110 小时评议0
帖子精华13积分43395金钱83703 荣誉559 人气630 评议0
核显性能不够。独显显存不足。
 ★  ★  ?《银河英雄传说》
UID1520650主题阅读权限40帖子精华0积分728金钱7843 荣誉1 人气2 在线时间4391 小时评议0
Lv.4游侠高级会员, 积分 728, 距离下一级还需 272 积分
帖子精华0积分728金钱7843 荣誉1 人气2 评议0
是时候更新换代了
2014年杰出版主勋章
2014年杰出版主勋章
任职满12个月
资深版主勋章
任职满24个月
白金会员勋章
用户积分达到6000
发帖数达到10000
版主评议达到4,勤于处理版务
游侠荣誉会员勋章
为游侠论坛长期做修改器、游戏mod、游戏资源的会员可获得
大头像勋章
永久勋章,统一售价:8888金币。购买地址:待定
《三国志12》汉化贡献勋章
《三国志12》汉化贡献勋章
精华数量达到10
荣誉达到150
高级荣誉勋章
荣誉达到500
剑阁工作组资深组员勋章
剑阁工作组资深组员勋章
Powered by后使用快捷导航没有帐号?
查看: 1481|回复: 36
新人欢迎积分1 阅读权限20积分32精华0UID6663849帖子金钱5 威望0
Lv.2, 积分 32, 距离下一级还需 18 积分
UID6663849帖子威望0 多玩草10 草
安装信息:
游戏内容完整无损。
游戏安装所需空间:7G以上
本游戏运行需要以下软件支持:
DirectX最新版
PhysX 9.09.0814
驱动之家下载页面:
vcredist_x86
已在游戏安装目录下的Redistributable文件夹中附带
为了尽可能缩减硬盘版制作体积,硬盘版中不附带DirectX最新版以及physX,若游戏无法顺利运行,请确认电脑中的上述软件是否为最新版本。
请耐心等待游戏安装过程及解压过程(以DOS对话框的形式出现)全部结束,由于压缩率较高,解压过程也相应较长,请耐心等待。出现“完成”按钮后方可完成游戏安装过程并顺利游戏。
硬盘版游戏卸载方法:运行游戏安装目录下的卸载程序将注册表清除,之后删除游戏安装目录即可。
【外部图片】
中文名称:极品飞车13:变速
英文名称:Need for Speed: Shift
发行时间:日
游戏类型:竞速
游戏语言:英文
开发厂商:Slightly Mad
发行厂商:EA Games
官方网站:游戏介绍:
  本作将由Slightly Mad游戏制作室、Black Box执行制作人Michael Mann及EA Games Europe高级副总裁Patrick Soderlund联手制作,将为玩家传递最为引人入胜的拟真驾驶体验。
  赛《极品飞车13变速》将以前所未有的方式再现驾驶高端赛车驰骋的真实感受。其激动人心的魅力特点包括了超级真实的驾驶员第一视角照相机以及全新的车损机制,让玩家深深陶醉于动作游戏的核心,以最先进的操控方式感受驾驶赛车无以伦比的速度与激情感受。
  EA市场经理Keith Munro表示,真实性是这款作品的最大特点,不会引入嘻哈和街头风格。他说:“城市底下竞速是过去有几代《极品飞车》的鲜明特色,而《Shift》会放弃这些,转而提供真实的驾驶体验,会让玩家感觉是在真正地极速飚车。”他还强调,汽车发烧友肯定会爱上这款作品,主流游戏玩家也能找到不一样的乐趣。
  至于新的赛车女郎,Keith Munro笑称他希望曾成功为《极品飞车9:最高通缉》代言的Josie Maran能够重出江湖。
  《Need for Speed: Shift》(极品飞车:变速),由出品过《GT Legends》和《GTR 2》的Slightly Mad Studios工作室负责开发,Black Box工作室制作人Michael Mann和EA欧洲分公司负责人Patrick Soderlund也都会参与其中。
  在风格上依然将保留系列前作的特点,照片级质量的出色画面和近似真实的驾驶感受依旧是游戏的主要卖点所在。
配置需求:
最低配置要求:
Pentium 4 3.2 GHz (3.4 GHz 针对 Vista)
1GB RAM (2GB 针对 Vista)
256MB 显存的显卡,支持 Pixel Shader 3 (PCI-Ex)
兼容 DirectX 9.0c 的声卡
10GB 剩余空间
Windows XP SP3 或者 Vista SP1
8x DVD 光驱
推荐配置要求:
Intel Core 2 Duo 2.5 GHz 或者 AMD64 X2 2 GHz
2GB RAM (3GB 针对 Vista)
512MB 显存的显卡,支持 Pixel Shader 3 (PCI-Ex)
兼容 DirectX 9.0c 的声卡
10GB 剩余空间
Windows XP SP3 或者 Vista SP1
8x DVD 光驱
【外部图片】
【外部图片】
【外部图片】
下载地址请访问
[ 本帖最后由 迷茫凌晶 于
13:18 编辑 ]
ベ誹袮莫屬℅
新人欢迎积分1 阅读权限20积分47精华0UID6577004帖子金钱10 威望0
Lv.2, 积分 47, 距离下一级还需 3 积分
UID6577004帖子威望0 多玩草10 草
新人欢迎积分0 阅读权限70积分9021精华0UID4201948帖子金钱10096 威望0
Lv.7, 积分 9021, 距离下一级还需 979 积分
UID4201948帖子威望0 多玩草15 草
这个算什么,又不提供下载
新人欢迎积分1 阅读权限70积分9388精华0UID5343045帖子金钱5840 威望0
Lv.7, 积分 9388, 距离下一级还需 612 积分
UID5343045帖子威望0 多玩草10 草
还真没下载地址
新人欢迎积分0 阅读权限50积分1722精华0UID5480589帖子金钱11181 威望0
Lv.5, 积分 1722, 距离下一级还需 778 积分
UID5480589帖子威望0 多玩草10 草
把头像和谐了。
总评分:&金钱 -1&
新人欢迎积分0 阅读权限50积分2424精华0UID5548256帖子金钱2189 威望0
Lv.5, 积分 2424, 距离下一级还需 76 积分
UID5548256帖子威望0 多玩草430 草
ls的头像是什么……
[url=http://Guoquan.net][/url]
|╲詆調&&壞.
新人欢迎积分0 阅读权限60积分4656精华0UID4392964帖子金钱5313 威望0
Lv.6, 积分 4656, 距离下一级还需 344 积分
UID4392964帖子威望0 多玩草15 草
我是来研究5楼头像的
破解了就好!
新人欢迎积分0 阅读权限50积分1668精华0UID4932631帖子金钱687 威望0
Lv.5, 积分 1668, 距离下一级还需 832 积分
UID4932631帖子威望0 多玩草25 草
1⒉冄1⒉號
新人欢迎积分1 阅读权限50积分2002精华0UID4612756帖子金钱1481 威望0
Lv.5, 积分 2002, 距离下一级还需 498 积分
UID4612756帖子威望0 多玩草18 草
5L会被河蟹么
新人欢迎积分1 阅读权限30积分77精华0UID6662362帖子金钱84 威望0
Lv.3, 积分 77, 距离下一级还需 173 积分
UID6662362帖子威望0 多玩草10 草
我有个极品飞车(Need For Speed) 7 地下狂飚(Underground) 的下载地址大家可以参考下
楼上的头像真漂亮!!
新人欢迎积分1 阅读权限30积分77精华0UID6662362帖子金钱84 威望0
Lv.3, 积分 77, 距离下一级还需 173 积分
UID6662362帖子威望0 多玩草10 草
喜欢驾驶高端赛车驰骋的感受!
新人欢迎积分0 阅读权限50积分1228精华0UID4313902帖子金钱8802 威望1
Lv.5, 积分 1228, 距离下一级还需 1272 积分
UID4313902帖子威望1 多玩草44 草
破显卡玩不了
新人欢迎积分1 阅读权限30积分59精华0UID6684618帖子金钱74 威望0
Lv.3, 积分 59, 距离下一级还需 191 积分
UID6684618帖子威望0 多玩草10 草
不错,不错哦!
新人欢迎积分0 阅读权限40积分455精华0UID4237336帖子金钱1065 威望0
Lv.4, 积分 455, 距离下一级还需 545 积分
UID4237336帖子威望0 多玩草10 草
Nyanko
新人欢迎积分1 阅读权限50积分1158精华0UID4414432帖子金钱1958 威望0
Lv.5, 积分 1158, 距离下一级还需 1342 积分
UID4414432帖子威望0 多玩草110 草
有地址没有啊??
Just because I'm losing,&&Doesn't mean I'm lost!
需要金钱:1100
Powered by
手机盒子客户端点击或扫描下载Setting Up OpenGL in an MFC Control
Share Articles
Setting Up OpenGL in an MFC Control
I haven't seen many articles on the Web integrate functionality other than just setting a basic OpenGL window inside of an existing MFC control. My goal in this tutorial is to set up, step-by-step, how to initialize an OpenGL rendering context inside of an MFC control such as a picture control, as well as basic functionality to draw based on a timer, resizing issues, basic camera functionality, and more. I will go step-by-step in the Microsoft Visual Studio .NET 2003 environment and it will be designed for all levels of understanding. I will add steps for the beginners for certain areas and perhaps steps that the more adept person can skip over and delve into what they're truly looking for. Anyway, I appreciate any kind of comments on this (good or bad) and will try my best to update it to everyone's liking. Thanks and enjoy!
Note: This article is a reprint from a tutorial on my Web site, . Please look at it for a more picture-oriented step-by-step tutorial.
Part I: Creating the Initial OpenGL Window
Step 1: Creating the Project
You will begin by starting a new MFC Dialog application project. File-&New-&Project... Select MFC Application from the Templates window and name it "oglMFCDialog". Where you place it on your hard drive is up to you. Just remember where you saved it.
When the MFC Application Wizard pops up, under Application Type select Dialog based and click the Finish button. Any additional preferences and features can be changed under User Interface Features. For my example, I just selected the bare minimum.
Step 2: Creating the Control
Navigate to the Resource View tab from the Solution Explorer tab, expand the Dialog folder, and double-click on the automatically generated IDD_OGLMFCDIALOG_DIALOG dialog box. You will need to add a control in which the OpenGL rendering context will be placed. A simple picture control will do fine, so select Picture Control from the Toolbox.
Note: If your Toolbox does not show up, simply go to View-&Toolbox to bring it up.
Drag and drop or select-drag the control onto your dialog window. Resize accordingly.
You will need to set some properties of the picture control. With the picture control selected, the properties window usually will be located on your bottom right of the environment. Set the following variables:
Visible: False
ID: IDC_OPENGL
You may be wondering why you set the Visible attribute to False. When you load the OpenGL rendering context inside of any MFC control, you will just use the control's window rect coordinates to draw the OpenGL stuff. For some odd reason, if the visibility of the picture control is set to True, the control will cover up all the OpenGL you draw inside of the rect.
Step 3: Adding the OpenGL Class
Next, to set up the OpenGL, I opted to keep it nice and neat and add a separate class for it. It's good practice to keep major components of a project in separate classes, so I will keep the OpenGL and the MFC separate.
To add a class, under the Solution Explorer tab, right-mouse click on the oglMFCDialog project in the tree and go to Add-&Add Class... Select Generic C++ Class from the template and click Open. When the C++ Class Wizard pops up, set the following variables:
Class name: COpenGLControl
Base class: CWnd
Access: public
Check Virtual destructor
Click the Finish button and you will have your new class added to the project.
Step 4: Adding Project Libraries
Because you will be accessing OpenGL's rendering functions, you also will need to add some libraries to link into the project. To do this, right-mouse click on the oglMFCDialog project in the tree once again and select Properties.
When the oglMFCDialog Property Pages box pops up, select Linker-&Input and set the following variables:
Additional Dependencies: opengl32.lib glu32.lib
Note: Do not put any spaces between the two *. simply type them just as I have listed above.
Step 5: Setting Up Class Variables
For the duration of the project, some local variables will need to be added to the OpenGLControl.h, both public and private, as well as two #include calls for the OpenGL functions to work. They are as follows:
#include &gl/gl.h&
#include &gl/glu.h&
class COpenGLControl : public CWnd
/******************/
/* PUBLIC MEMBERS */
/******************/
UINT_PTR m_unpT
/*******************/
/* PRIVATE MEMBERS */
/*******************/
// Window information
m_originalR
Important Note: I keep the functions of this project in a specific order. This is rather important because, if some are instantiated before others, you will get a compiler error due to protected member calls. So, I have set them up in the following order:
Constructor and destructor
Manually added functions
Automatically added "afx_msg" functions
The DECLARE_MESSAGE_MAP() call
Step 6: Adding the oglCreate Function
A new function will need to be added to both the OpenGLControl.h and OpenGLControl.cpp files. The function will be responsible for setting up some basic window variables and function calls important to the MFC; I named this function oglCreate. The portion of code below to be added to the header file can be placed under a new public routine section.
OpenGLControl.h:
void oglCreate(CRect rect, CWnd *parent);
OpenGLControl.cpp:
void COpenGLControl::oglCreate(CRect rect, CWnd *parent)
CString className = AfxRegisterWndClass(CS_HREDRAW |
CS_VREDRAW | CS_OWNDC, NULL,
(HBRUSH)GetStockObject(BLACK_BRUSH), NULL);
CreateEx(0, className, "OpenGL", WS_CHILD | WS_VISIBLE |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0);
// Set initial variables' values
m_oldWindow
m_originalRect =
Step 7: Adding the OnPaint Function
A message class function will need to be added next. How this differs from the previous function is rather simple. MFC calls certain messages (with the WM_ prefix) when specific events happen within the program. Some of the main ones are OnPaint, OnSize, OnCreate, and so forth. To add one of these through Visual Studio, there is a Messages button located in the Properties dockable window with an icon next to the lightning bolt icon. If your cursor is inside the proper *.cpp or *.h file (in your case, for example, OpenGLControl.cpp), this is where you need to add these kinds of messages.
Having said that, first you will need to create an OnPaint message by locating the WM_PAINT message under the Properties-&Messages window. Then, select &Add& OnPaint from the dropdown list. You will notice that the message function has been added to both the OpenGLControl.h and OpenGLControl.cpp. But, instead of like a regular user-added function, it will have the prefix "afx_msg" and will also have a call placed in the message map at the top of the *.cpp file. I recommend not changing anything added automatically by Visual Studio unless you know what you're changing.
Inside the OnPaint function, only a little bit of the automatically generated code will need to be changed. You will be rendering (or "painting") the OpenGL window unlike the MFC windows' rendering, in that you will be doing it through a timer. This is in case the need to clamp to a certain frame rate arises later on in a project you do. To render the window control through a timer, the OnPaint cannot be called l therefore, adding a simple line of code and commenting out (or deleting) the old calls is needed. Following is the code that will need to be added into this OnPaint function in the OpenGLControl.cpp file:
OpenGLControl.cpp:
void COpenGLControl::OnPaint()
//CPaintDC dc(this);
// device context for painting
ValidateRect(NULL);
Step 8: Adding the OnCreate Function
Next, add another message class like you did in the previous step, but this time select the WM_CREATE message and from the dropdown, select &Add& OnCreate. Again, the new class will be added to both the *.h and *.cpp files.
As far as the code calls for this, you will only need to add one line of code and that's a call to your next manually added function, the oglInitialize function.
Note: Of course, this new function hasn't been added yet, so if you try to run it you will get a compiler error.
OpenGLControl.cpp:
int COpenGLControl::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
oglInitialize();
Step 9: Adding the oglInitialize Function
As mentioned in the previous step, the next manually added function, the oglInitialize function, is called when your OpenGL class is created (by means of the OnCreate message). The oglInitialize function will be responsible for setting up all of the information OpenGL needs to render. These include the pixel format, rendering context, and also a clear color to make sure that it's swapping the buffers correctly.
Note: The last line of code in the *.cpp portion below calls an OnDraw function, which has not yet been created. Therefore, another compiler error will occur if you try running this.
OpenGLControl.h:
void oglInitialize(void);
OpenGLControl.cpp:
void COpenGLControl::oglInitialize(void)
// Initial Setup:
static PIXELFORMATDESCRIPTOR pfd =
sizeof(PIXELFORMATDESCRIPTOR),
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
// bit depth
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// z-buffer depth
0, 0, 0, 0, 0, 0, 0,
// Get device context only once.
hdc = GetDC()-&m_hDC;
// Pixel format.
m_nPixelFormat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, m_nPixelFormat, &pfd);
// Create the OpenGL Rendering Context.
hrc = wglCreateContext(hdc);
wglMakeCurrent(hdc, hrc);
// Basic Setup:
// Set color to use when clearing the background.
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClearDepth(1.0f);
// Turn on backface culling
glFrontFace(GL_CCW);
glCullFace(GL_BACK);
// Turn on depth testing
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
// Send draw request
OnDraw(NULL);
Step 10: Adding the OnDraw Function
Next, the OnDraw function mentioned in the previous step's oglInitialize function needs to be added. This will have to act as a message function, but will need to be added manually. And as you might gather already, the "afx_msg" prefix will need to be added to the function's declaration. You will notice in the *.cpp portion that you don't actually call any procedures yet, just a commented TODO. This will be mentioned later on in the tutorial, for camera controls and such.
Note: If you try running this now, it will compile correctly, but unfortunately still nothing is being drawn into the control. This is due to the change you made in OnPaint.
OpenGLControl.h:
afx_msg void OnDraw(CDC *pDC);
OpenGLControl.cpp:
void COpenGLControl::OnDraw(CDC *pDC)
// TODO: Camera controls.
Setting Up OpenGL in an MFC Control
Step 11: Adding the OnTimer Function
It's now time to add what will succeed the previous functionality of the OnPaint through a timer. Add a new message class by selecting the WM_TIMER message and select &Add& OnTimer from the dropdown list to create the function.
The code of the OnTimer function is rather straightforward. Every time a timer is called in this class, it will run through this function. Therefore, the value passed through the function automatically houses an unsigned integer corresponding to the timer you create manually. Using a select statement, I created the case for the timer you will render with. The basic "draw then swap buffers" routine is now placed inside this timer. In the first steps of this tutorial, though, you won't actually draw images to the screen, but only correctly swap the buffers to the clear color.
OpenGLControl.cpp:
void COpenGLControl::OnTimer(UINT nIDEvent)
switch (nIDEvent)
// Clear color and depth buffer bits
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw OpenGL scene
// oglDrawScene();
// Swap buffers
SwapBuffers(hdc);
CWnd::OnTimer(nIDEvent);
Step 12: Adding the OnSize Function
The last message function you need to add will be the OnSize function. Like you've done before, select the WM_SIZE message and select &Add& OnSize from the dropdown to create the function.
The OnSize function is called when the window is resized. To prevent the OpenGL rendering from getting all wacky from resizing the window, a few things such as the perspective and viewport need to be tweaked. In the tutorial, you won't actually resize the control according to the window, but that could be achieved in this function if the need arises.
OpenGLControl.cpp:
void COpenGLControl::OnSize(UINT nType, int cx, int cy)
CWnd::OnSize(nType, cx, cy);
if (0 &= cx || 0 &= cy || nType == SIZE_MINIMIZED)
// Map the OpenGL coordinates.
glViewport(0, 0, cx, cy);
// Projection view
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Set our current view perspective
gluPerspective(35.0f, (float)cx / (float)cy, 0.01f, 2000.0f);
// Model view
glMatrixMode(GL_MODELVIEW);
You are now done with the COpenGLControl class (the initial setup, at least). So, the next step is to integrate the class into your main MFC window, the CoglMFCDialogDlg class.
Step 13: Customizing the Main MFC Dialog Class
Your last step is to integrate your OpenGL class into the main MFC dialog. This is done rather painlessly. First, inside the oglMFCDialogDlg.h file you will need to #include the created OpenGL class header file and also create an instance of the COpenGLControl class as a local variable to this class.
oglMFCDialogDlg.h:
#include "OpenGLControl.h"
class CoglMFCDialogDlg : public CDialog
COpenGLControl m_oglW
Next, inside of the oglMFCDialogDlg.cpp file, add to the already existing OnInitDialog function before the return statement the following code to create your OpenGL class inside the picture control you created and start up the timer to render the scene.
Note: For initial test purposes, I set the timer to 1 millisecond to call your timer, or a non-clamp.
oglMFCDialogDlg.cpp::OnInitDialog:
// Get size and position of the picture control
GetDlgItem(IDC_OPENGL)-&GetWindowRect(rect);
// Convert screen coordinates to client coordinates
ScreenToClient(rect);
// Create OpenGL Control window
m_oglWindow.oglCreate(rect, this);
// Setup the OpenGL Window's timer to render
m_oglWindow.m_unpTimer = m_oglWindow.SetTimer(1, 1, 0);
Step 14: Initial OpenGL Control Results
And there you have it. Now you should have the black clear color constantly being swapped through the buffers! Now, from here you can add a drawing function to do all your rendering work and place that in the OnTimer function where the commented line suggests.
[oglTut010.jpg]
Part II: Extending the OpenGL Functionality (Extras)
Step 15: Drawing Geometrical Shapes
The next step would be to start drawing some test shapes in your OpenGL control. Unfortunately, you won't be able to actually completely see them yet until you set up some kind of camera system. Without a camera pointing you to a certain point to look at the shapes you draw, the shapes created will just be placed on the origin of the camera and thus won't be viewable. So, if you want to see what you draw first instead, skip down to Step 16, Setting Up a Maya-Style Camera, in which you will create an Alias|Wavefront Maya-style camera (rotate/zoom/translate with mouse buttons). But, I chose to start drawing and setting the camera up afterwards instead for this tutorial.
Anyway, drawing the shapes on this tutorial just create a standard cube by drawing the six sides with quads (4-vertex shapes). If you recall in the OnTimer function, there's a commented-out call to a non-existant oglDrawScene you now will create this function.
OpenGLControl.h:
void oglDrawScene(void);
OpenGLControl.cpp:
void COpenGLControl::oglDrawScene(void)
// Wireframe Mode
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_QUADS);
// Top Side
glVertex3f( 1.0f, 1.0f,
glVertex3f( 1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f, -1.0f);
glVertex3f(-1.0f, 1.0f,
// Bottom Side
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f( 1.0f, -1.0f, -1.0f);
glVertex3f( 1.0f, -1.0f,
glVertex3f(-1.0f, -1.0f,
// Front Side
glVertex3f( 1.0f,
1.0f, 1.0f);
glVertex3f(-1.0f,
1.0f, 1.0f);
glVertex3f(-1.0f, -1.0f, 1.0f);
glVertex3f( 1.0f, -1.0f, 1.0f);
// Back Side
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f,
1.0f, -1.0f);
glVertex3f( 1.0f,
1.0f, -1.0f);
glVertex3f( 1.0f, -1.0f, -1.0f);
// Left Side
glVertex3f(-1.0f, -1.0f, -1.0f);
glVertex3f(-1.0f, -1.0f,
glVertex3f(-1.0f,
glVertex3f(-1.0f,
1.0f, -1.0f);
// Right Side
glVertex3f( 1.0f,
glVertex3f( 1.0f, -1.0f,
glVertex3f( 1.0f, -1.0f, -1.0f);
glVertex3f( 1.0f,
1.0f, -1.0f);
Now, one last thing you'll need to do is uncomment the commented-out call to the oglDrawScene function in the OnTimer function.
OpenGLControl.cpp::OnTimer:
// Clear color and depth buffer bits
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Draw OpenGL scene
oglDrawScene();
// Swap buffers
SwapBuffers(hdc);
Step 16: Setting Up a Maya-Style Camera
The Maya-style camera refers to the camera system used in Alias|Wavefront Maya in which the mouse button-&drag performs a certain operation: Left: Rotate, Right: Zoom, and Middle: Translate. To do this, you'll need to make an OnMouseMove function call:
Select the WM_MOUSEMOVE message and select from the dropdown, &Add& OnMouseMove, to create the function. Inside this newly created function, you'll need to add the code to perform each of the buttons' given operations. If you recall from early on in the tutorial, you created some member variables for rotate, zoom, and position. You'll use these variables and set their new values according to the position variables passed into the function by Windows.
OpenGLControl.h:
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
OpenGLControl.cpp:
void COpenGLControl::OnMouseMove(UINT nFlags, CPoint point)
int diffX = (int)(point.x - m_fLastX);
int diffY = (int)(point.y - m_fLastY);
= (float)point.x;
= (float)point.y;
// Left mouse button
if (nFlags & MK_LBUTTON)
m_fRotX += (float)0.5f * diffY;
if ((m_fRotX & 360.0f) || (m_fRotX & -360.0f))
m_fRotX = 0.0f;
m_fRotY += (float)0.5f * diffX;
if ((m_fRotY & 360.0f) || (m_fRotY & -360.0f))
m_fRotY = 0.0f;
// Right mouse button
else if (nFlags & MK_RBUTTON)
m_fZoom -= (float)0.1f * diffY;
// Middle mouse button
else if (nFlags & MK_MBUTTON)
m_fPosX += (float)0.05f * diffX;
m_fPosY -= (float)0.05f * diffY;
OnDraw(NULL);
CWnd::OnMouseMove(nFlags, point);
Furthermore, I have put a few initial variable settings into the constructor of the COpenGLControl class that help the camera work properly.
OpenGLControl.cpp:
COpenGLControl::COpenGLControl(void)
m_fPosX = 0.0f;
// X position of model in camera view
m_fPosY = 0.0f;
// Y position of model in camera view
m_fZoom = 10.0f;
// Zoom on model in camera view
m_fRotX = 0.0f;
// Rotation on model in camera view
m_fRotY = 0.0f;
// Rotation on model in camera view
Now, the last step to do is, if you recall from when you first created the OnDraw function, to change the commented TODO of the camera controls to the following:
OpenGLControl.cpp::OnDraw:
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -m_fZoom);
glTranslatef(m_fPosX, m_fPosY, 0.0f);
glRotatef(m_fRotX, 1.0f, 0.0f, 0.0f);
glRotatef(m_fRotY, 0.0f, 1.0f, 0.0f);
[oglTut014.jpg]
Step 17: Resizing the Window Correctly:
Resizing windows in MFC are a rather tedious job, compared to perhaps Visual Basic, but it can
and once you've done it one time, you reuse the code pretty much forever. So, here's the way I had figured it out and still use to this day. It involves both OnSize functions for both MFC and OpenGL.
First, go into your oglMFCDialogDlg message function and create an OnSize function with the same technique you've used throughout this tutorial. This will generate your OnSize for the MFC portion, but you'll n the entire OnSize class will now look like this:
oglMFCDialogDlg.cpp:
void CoglMFCDialogDlg::OnSize(UINT nType, int cx, int cy)
CDialog::OnSize(nType, cx, cy);
switch (nType)
case SIZE_RESTORED:
if (m_oglWindow.m_bIsMaximized)
m_oglWindow.OnSize(nType, cx, cy);
m_oglWindow.m_bIsMaximized =
case SIZE_MAXIMIZED:
m_oglWindow.OnSize(nType, cx, cy);
m_oglWindow.m_bIsMaximized =
You may have noticed this changes the state of a variable you have not yet created, so you now will do the OpenGL window portion, inside your already created OnSize message function there. So, place the following code right after the code that's already inside the OnSize function:
OpenGLControl.cpp:
switch (nType)
// If window resize token is "maximize"
case SIZE_MAXIMIZED:
// Get the current window rect
GetWindowRect(m_rect);
// Move the window accordingly
MoveWindow(6, 6, cx - 14, cy - 14);
// Get the new window rect
GetWindowRect(m_rect);
// Store our old window as the new rect
m_oldWindow = m_
// If window resize token is "restore"
case SIZE_RESTORED:
// If the window is currently maximized
if (m_bIsMaximized)
// Get the current window rect
GetWindowRect(m_rect);
// Move the window accordingly (to our stored old window)
MoveWindow(m_oldWindow.left,
m_oldWindow.top - 18,
m_originalRect.Width() - 4,
m_originalRect.Height() - 4);
// Get the new window rect
GetWindowRect(m_rect);
// Store our old window as the new rect
m_oldWindow = m_
And that's about it. Quite simple, no? Feel free to post any comments whatsoever on this article. T hope it helps!
Top White Papers and Webcasts
The mobile revolution and the need for mobile apps have created an unprecedented set of challenges for IT organizations. This eBook discuss these challenges and how organizations can address them by making their mobile app development processes more efficient and more effective.
Employees must exchange sensitive emails with customers and partners. These emails might contain protected health information, protected financial information, or corporate information that should not be made public. Globalscape& Mail Express& allows you to encrypt the emails that it manages so that no one but the sender and recipient--not even the administrator--can view the contents of the email.
"Secure the Transfer of Sensitive Emails" is the property of GlobalSCAPE
Most Popular Programming Stories
More for Developers
Copyright 2015 QuinStreet Inc. All Rights Reserved.
Thanks for your registration, follow us on our social networks to keep up-to-date

我要回帖

更多关于 极品飞车 的文章

 

随机推荐