|
|
8/21/2008 前天,电脑终于接到了物流的电话通知去领行李,打开箱子,插上电源,万幸,还都好用,省却了一番修理的功夫。不过所谓的插上电源并不是主机和显示器一起插上电源,在毕业邮寄行李的时候电源线少了一根,周围没有教化那样的地方,不过好在楼下不远处就有一个修理家用电器的,顺手去买了一根电饭锅的电源线,竟然也是好用的,甚幸至哉。
宽带是很久就已经开始筹备的了,半月前去排队,一个星期前交钱,上周日装好的,就只等这个姗姗来迟的电脑了,嘿嘿
怎么感觉打字一卡一卡的
难道微软的BLOG都能卡到这个神奇的程度?
忽然想起来奥运会开幕式上那个传说的蓝屏了,不知道是真有其事还是杜撰,但是微软嘛,我想还是有可能的~~~
【转载】奥运开幕式上的Windows蓝屏照
我们已经知道,鸟巢的灯光和投影显示系统使用了上百台Windows XP Embedded系统的服务器产品,而在开幕式主火炬点火的关键时刻,其中一台投影服务器正巧出现了蓝屏。如果之前的照片还不足以显出此次蓝屏的尴尬程度的话,下面这张照片应该可以给你一个更清楚的认识。 Windows蓝屏照 没有错,正当李宁在空中跑道大步迈进的时候,蓝屏就在他的身旁。不知道微软看到这样的照片心里会是怎样的想法。 尽管之前微软公司嵌入式视窗产品部项目经理为Windows XP Embedded (XPe)系统在 奥运会开幕式中所担当的重要角色和良好表现兴奋不已,不过在另一些角落XPe可能还不够稳定,下面的图片据说昨晚拍摄于H区3层顶棚。 Windows蓝屏照 Windows蓝屏照 5/28/2008
|
OpenGL in a Mfc dialog
|
|
Welcome to the second OpenGL tutorial on SteinSOFT.net! I've decided to write about this topic because I thought it would be rather interesting and I have seen many people wanting to do something like that. So what is it indeed? It's simply a little integrated window in a normal dialog in which some OpenGL shapes are drawn. On the one side you have OpenGL and on the other standard Windows controls. If you can't imagine how this could look like, take a look at my project OpenGLDialog.
Let's quickly dive into this exciting topic;). There isn't much theory about which one could speak. That's good... It all begins with a new Mfc project. Create a new project using the Mfc application wizard. Choose the third option, a dialog-based application. In the following dialogs you can pratically disable/enable whatever you want; it doesn't matter in this case.
You should now have your little Mfc app ready. We will start with the most important thing of your project, the little OpenGL window in the corner.
The Integrated OpenGL WindowOkay you have your little OpenGL based project but.. what next? The fastest and easiest thing first;). That is to create our dialog in the dialog editor. When the project has been created, this should also be the first thing you see in MSDEV. How you arrange your little dialog is irrelevant, the only thing we have to do is to create a new static text field. This text field seems to be useless at first sight; it is indeed a template for our OpenGL window. The window will have the exactely the same size and position as this little static control. Later on if you wan t to change the window's positions or size, you won't need to change he code, but only this little texfield in the dialog editor.
Here you see the dialog I created. It has only two little textfields and two buttons on the bottom. These are intended to show how the OpenGL window works together with the other standard Windows controls. The only important control is the text field on the bottom left. It has no text so it is actually invisible. Ok then add a text field to your dialog and place it where you want to have the OpenGL window later on in your application. The name is not important, but don't call it ID_STATIC as MSDEV does it by default. We could not get its position and size later on. I simply called it ID_OPENGL_WINDOW. It's the box I selected on the image on the left. Delete the caption the field has as default and make sure that it is marked as invisible (Under properties > Behaviour, uncheck the Visible property).
So after this easy step, we have our little dialog completeted and we can move on to coding. It will be more difficult.. but don't panic, it's still not too hard. What we have to do first, is to create a new class derived from CWnd. It will be then the little OpenGL window on the bottom. So then create a new class called COpenGLControl with CWnd as base class. Click on Insert | New Class... or something like this,
The next steps are the following: * Create the window * Create an OpenGL rendering context * Setup basic OGL things (viewport, state machine etc.)
Let the coding begin! The very first thing to do is to add the needed variables and objects to COpenGLControl. To create an OpenGL rendering context, I'll use OpenGLDevice from the code section. You could also use your own functions to set the pixelformat etc. but I I use this class because it's very easy ;-). The three variables are: OpenGLDevice openGLDevice (don't forget to include the header!), CClientDC* dc the window's device context and float rotation the rotation of the triangle we'll draw to this little window. Here is the code of the constructor and destructor:
COpenGLControl::COpenGLControl()
{
dc = NULL;
rotation = 0.0f;
}
COpenGLControl::~COpenGLControl()
{
if (dc) //Only delete dc when really allocated
{
delete dc;
}
}
The first step above are done easily. It is accomplished in Create(..) of COpenGLControl, the function we will create now. So add Create(CRect rect, CWnd* parent) to COpenGLControl. Here's the code:
void COpenGLControl::Create(CRect rect, CWnd *parent)
{
//Register window class
CString className = AfxRegisterWndClass(
CS_HREDRAW | CS_VREDRAW | CS_OWNDC,
NULL,
(HBRUSH)GetStockObject(BLACK_BRUSH),
NULL);
//Finally create the window
CreateEx(
0,
className,
"OpenGL",
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
rect,
parent,
0);
}
In this function we will create the little OpenGL window and it will have exactely the same size as the rect specified by rect. Secondly it will be a child of parent which will be the main dialog later on. The next step is to create the OpenGL rendering context. This is done in the message handler for WM_CREATE. So add the handler for this message. Here's the code:
int COpenGLControl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
dc = new CClientDC(this); //Get device context of window
openGLDevice.create(dc->m_hDC); //Create opengl rendering context
InitGL();
//DONE
return 0;
}
Next add the message handler for WM_SIZE in COpenGLControl. We'll set the OpenGL viewport in it. The code:
void COpenGLControl::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
if (cy == 0)
{
cy = 1;
}
glViewport(0,0,cx,cy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0f,1.0f,-1.0f,1.0f,1.0f,-1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
Nothing special will be done here. The viewport will be set up as well as an orthogonal projection. It is similar to any other OpenGL application. The next function is InitGL(). It will be called when the windows is created and here is the best place to initialize some OpenGL things, like lighing or texture mapping. Add void InitGL() to COpenGLControl. Code:
void COpenGLControl::InitGL()
{
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
}
Very trivial code here. You should know what we do here or you are on a slightly wrong place here ;-). The next function is actually the function that draws finally something on the screen. It's void DrawGLScene():
void COpenGLControl::DrawGLScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//***************************
// DRAWING CODE
//***************************
//Rotate the triagle
glRotatef(rotation,0.0f,1.0f,0.0f);
glBegin(GL_TRIANGLES);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(1.0f,-1.0f,0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f,0.0f);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(0.0f,1.0f,0.0f);
glEnd();
SwapBuffers(dc->m_hDC);
}
This function simply draws a colored triangle rotated by rotation degrees. It will be called in the next function. It's the message handler for WM_PAINT, the window message that is called everytime the window has to be refreshed. Add the handler to COpenGLControl and fill in the following code:
void COpenGLControl::OnPaint()
{
rotation += 0.01f;
if (rotation >= 360.0f)
{
rotation -= 360.0f;
}
/** OpenGL section **/
openGLDevice.makeCurrent();
DrawGLScene();
CWnd::OnPaint();
}
First we update rotation so that our triangle is actually rotated and then we call DrawGLScene() that draws the little shape. What is very important is here is the call to openGLDevice.makeCurrent(). This function ensures the the right OpenGL device context is selected before drawing to the window. Like this it's possible to have more than one OpenGL control placed in a dialog.
The last and very important message handler WM_ERASEBKGND makes sure that the dialog message queue isn't overloaded - WM_ERASEBKGND is always sent to the window when it's background has to be erased. Add the handler to this message to COpenGLControl and in the following code:
BOOL COpenGLControl::OnEraseBkgnd(CDC* pDC)
{
//we've erased it - at least we do so
return TRUE;
}
That's all for COpenGLControl. The class itself is done. The next step is to update a little the parent class, the dialog. Ok then, get ready.
The Dialog ClassThere isn't left much to do now, only some little coding and compared to the last exhausting and deadly difficult part, it is a real childplay.. First we add an instance of COpenGLControl to our dialog. Do this in the header file of your dialog class (I called it here COpenGLDialogDlg with COpenGLDialogDlg.h as header). Here's a code snippet:
//In COpenGLDialogDlg.h
//..
//Very important
#include "OpenGLControl.h"
class COpenGLDialogDlg : public CDialog
{
//Other things..
//..
protected:
//Our instance of COpenGLControl
COpenGLControl openGLControl;
//..
};
So our dialog class now knows the instance and we can move on to final step. This is done in OnInitDialog() of COpenGLDialogDlg which should be implemented automatically by the Mfc wizard. Here we initialize our little OpenGL window and tell it where it is positioned. The last code snippet for today.. here:
BOOL COpenGLDialogDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//.. OTHER THINGS ARE DONE ..
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
// TODO
//Get Size and position of the template textfield we created
//before in the dialog editor
CRect rect;
GetDlgItem(IDC_OPENGL_WINDOW)->GetWindowRect(rect);
//Convert screen coordinates to client coordinates
ScreenToClient(rect);
//Create the OpenGL window using the size and set this dialog as parent
openGLControl.Create(rect,this);
return TRUE;
}
That's it! In this little code snippet you see why the previously created textfield is useful: we get its window-rect, its size and position on the screen, and call COpenGLControl::Create(..) with it as parameter. GetDlgItem(IDC_OPENGL_WINDOW) returns a pointer of CWnd to this control, IDC_OPENGL_WINDOW. If you remember we gave the little textfield template a name and with it we can refer to it and get info about without creating a new instance.
Now everything's done! Compile the project and you'll have a little OpenGL window integrated in your normal dialog. The good thing is that you don't have to change the code anymore if you want to move or resize the OpenGL window. Simply do it in the dialog editor with the textfield template. You could now extend this program. You could use this base code to create an interactive info box for one of your projects with a dynamic logo drawn with OpenGL. There so many things possible.
If you have further questions or comments or you had some problems then simply mail me or ask your questions in the message board. I'll try to answer them. Happy Coding and see you in the next tutorial!
Downloads: OpenGLDialog source code (VC++) | 1/27/2008 超可爱兔子们,应该是我见过最全的兔子了
一
小白兔蹦蹦跳跳到面包房,问:“老板,你们有没有一百个小面包啊?” 老板:“啊,真抱歉,没有那么多” “这样啊。。。”小白兔垂头丧气地走了。 第二天,小白兔蹦蹦跳跳到面包房,“老板,有没有一百个小面包啊?” 老板:“对不起,还是没有啊” “这样啊。。。”小白兔又垂头丧气地走了。 第三天,小白兔蹦蹦跳跳到面包房,“老板,有没有一百个小面包 啊?” 老板高兴的说:“有了,有了,今天我们有一百个小面包了!!” 小白兔掏出钱:“太好了,我买两个!”
二
有一只小白兔快乐地奔跑在森林中, 在路上牠碰到一只正在卷大麻的长颈鹿, 小白兔对长颈鹿说: "长颈鹿长颈鹿,你为什么要做伤害自己的事呢? 看看这片森林多么美好,让我们一起在大自然中奔跑吧!" 长颈鹿看看大麻烟,看看小白兔,于是把大麻烟向身后一扔, 跟着小白兔在森林中奔跑.
后来牠们遇到一只正在准备吸古柯碱的大象, 小白兔对大象说: "大象大象,你为什么要做伤害自己的事呢? 看看这片森林多么美好,让我们一起在大自然中奔跑吧!" 大象看看古柯碱,看看小白兔,于是把古柯碱向身后一扔, 跟着小白兔和长颈鹿在森林中奔跑.
后来牠们遇到一只正在准备打viper的狮子, 小白兔对狮子说: "狮子狮子,你为什么要做伤害自己的事呢? 看看这片森林多么美好,让我们一起在大自然中奔跑吧!" 狮子看看针筒,看看小白兔,于是把针筒向身后一扔, 冲过去把小白兔狠揍了一顿. 大象和长颈鹿吓得直发抖:"你为什么要打小白兔呢? 牠这么好心,关心我们的健康又叫我们接近大自然." 狮子生气地说:"这个混蛋兔子,每次嗑了摇头丸就拉着我 像白痴一样在森林里乱跑."
三
第一天,小白兔去河边钓鱼,什么也没钓到,回家了。 第二天,小白兔又去河边钓鱼,还是什么也没钓到,回家了。 第三天,小白兔刚到河边,一条大鱼从河里跳出来,冲着小白兔大叫: 你他妈的要是再敢用胡箩卜当鱼饵,我就扁死你!
四 为了测试美国, 香港, 中国大陆三地pol.ice的实力, 联合国将三只兔子放在三个森林中, 看三地pol.ice谁先找出兔子. 第一个森林前是美国pol.ice, 他们先花整整半天时间开会制定作战计划, 严格分工, 然后派特种部队快速进入森林进行地毯式搜索, 结果开会耽搁了时间, 兔子跑了, 任务失败! 然后轮到香港pol.ice, 他们派了一百多号人和几十辆警车在森林外一字排开, 由带头人用喇叭喊话:"兔子,兔子,你已经被包围了, 快出来投降......" 半天过去了, 没动静. 飞虎队进入森林, 搜索一遍, 没结果, 任务失败! 最后是中国pol.ice, 只有四个, 先打了一天麻将, 黄昏时一人拿一警棍进入森林,没五分钟, 听到森林里传来一阵动物的惨叫, 中国pol.ice一人抽着一根烟有说有笑的出来, 后面拖着一 只鼻青脸肿的熊, 熊奄奄一息的说到:"不要再打了, 我就是兔子......." 五
小白兔在森林里散步,遇到大灰狼迎面走过来,上来“啪啪”给了小白兔两个大耳贴子,说“我让你不戴帽子”。小白兔很委屈的撤了。 第二天,她戴着帽子蹦蹦跳跳的走出家门,又遇到大灰狼,他走上来“啪啪”又给了小白兔两个大嘴巴,说“我让你戴帽子。” 兔兔郁闷了。思量了许久,最终决定去找森林之王老虎投诉。 说明了情况后,老虎说“好了,我知道了,这件事我会处理的,要相信组织哦”。当天,老虎就找来自己的哥们儿大灰狼。“你这样做不妥啊,让老子我很难办嘛。”说罢抹了抹桌上飘落的烟灰:“你看这样行不行哈?你可以说,兔兔过来,给我找块儿肉去!她找来肥的,你说你要瘦的。她找来瘦的,你说你要肥的。这样不就可以揍她了嘛。当然,你也可以这样说。兔兔过来,给我找个女人去。她找来丰满的,你说你喜欢苗条的。她找来苗条的,你说你喜欢丰满的。可以揍她揍的有理有力有节”。大灰狼频频点头,拍手称快,对老虎的崇敬再次冲向新的颠峰。不料以上指导工作,被正在窗外给老虎家除草的小白兔听到了。心里这个恨啊。 次日,小白兔又出门了,怎么那么巧,迎面走来的还是大灰狼。大灰狼说:“兔兔,过来,给我找块儿肉去。”兔兔说:“那,你是要肥的,还是要瘦的呢?”大灰狼听罢,心里一沉,又一喜,心说,幸好还有B方案。他又说:“兔兔,麻利儿给我找个女人来。”兔兔问:“那,你是喜欢丰满的,还是喜欢苗条的呢?”大灰狼沉默了2秒钟,抬手更狠的给了兔兔两个大耳帖子。“靠,我让你不戴帽子。” 六
熊和兔子在森林里便便,完了熊问兔子“你掉毛吗?” 兔子说“不掉~” 于是熊就拿起兔子擦XXXXX。
七
有一只兔子非礼了一只狼(这只兔子很强吧), 然后就跑了,狼愤而追之, 兔子眼看狼快要追上了, 便在一棵树下坐下来, 戴起墨镜,拿张报纸看, 假装什么事也没有发生过, 这时狼跑来了,看见坐在树下的兔子, 问道:"有没有看见一只跑过去的兔子!" 兔子答道:"是不是一只非礼了狼的兔子?" 狼大呼:"不会吧!这么快就上报纸了!!!" 八
一天一只小白兔来到一家商店问老板:“老板,有胡萝卜吗?” 老板摇摇头:“没有。” 小白兔听完就“嗖”的跑了。 第二天小白兔又来到这家商店问:“老板,有胡萝卜吗?” 老板生气的摇摇头:“没有。” 小白兔听完就“嗖”的跑了。 第三天小白兔又来到这家商店问:“老板,有胡萝卜吗?” 老板愤怒的大喊:“没有没有!再问我就用钳子把你的牙齿拔掉!” 小白兔听完就“嗖”的跑了。 第四天小白兔又来到这家商店,怯生生的问:“老板,有钳子吗?” 老板说:“没有。” 小白兔于是问:“有胡萝卜吗?”
九 不知道过了多少天,一只小黑兔来到这家商店问老板:“老板,有胡萝卜吗?” 老板生气的摇摇头:“没有。” 小黑兔听完就“嗖”的跑了。 第二天小黑兔又来到这家商店问:“老板,有胡萝卜吗?” 老板非常生气:“没有没有!再问我就用钳子把你的牙齿拔掉!” 小黑兔听完就“嗖”的跑了。 第三天小黑兔又来到这家商店,怯生生的问:“老板,有钳子吗?” 老板生气的说:“没有。” 小黑兔于是问:“有胡萝卜吗?” 老板愤怒了,捉住小黑兔,拿出一把小锤子,把小黑兔的牙齿敲掉了。 第四天小黑兔又来到这家商店,含糊不清的问:“老板,有胡萝卜汁吗?”
十 长颈鹿说:"小兔子,真希望你能知道有一个长脖子是多么的好。无论什么好吃的东西,我吃的时候都会慢慢的通过我的长脖子,那美味可以长时间的享受。" 兔子毫无表情的看着他。 "并且,在夏天,兔子,那凉水慢慢的流过我的长脖子,是那么的可口。有个长脖子真是太好了!兔子,你能想象吗?" 兔子慢悠悠的说:"你吐过吗?"
十一
一天,袋鼠开着车在乡村小路上转悠,突然看到小白兔在路中央,耳朵及身体几乎完全趴在地上似乎在听什么... 于是..袋鼠停下车很好奇地问:“小白兔,请问一下你在听什么?” “半小时前这里有一辆大货车经过...” “哇靠..这么神!..你是怎么知道的?..” “他XX的!我的脖子和腿就是这么断的..” 十二
蚂蚁在森林里走,突然遇到一只大象,蚂蚁连忙一头钻进土里,伸出一只腿。 小白兔见了很好奇,问: 你在干什么? 蚂蚁悄悄对它说: 嘘……别出声,看我绊丫一跟头……
十三 有一天兔子在一个山洞前写东西,一只狼走过来问:“兔子你在写些什么? ” 兔子答曰:“我在写论文。” 狼又问:“什么题目?” 兔子答曰:“我在写兔子是怎样把狼吃掉的。” 狼听后哈哈大笑,表示不相信。 兔子说:“你跟我来。”然后把它带进了山洞之后,兔子又继续在山洞前写着。这时又来了一只狐狸问:“兔子,你在写些什么?” 兔子答曰:“我在写论文。” 狐狸问:“什么题目?” 兔子答曰:“兔子是如何把一只狐狸吃掉的。” 狐狸听完后哈哈大笑的,表示不信。 兔子说:“你跟我来。”之后把它带进了山洞,过了一会儿兔子又独自一个人走出了山洞,继续写它的论文。 此时在山洞的里面一只狮子正坐在一堆白骨上剔着牙,还一边看着兔子的论文:一个动物的能力大小,不是看它的力量有多大,而是看它的幕后老板是谁!
十四 在一个精神病院里,有一天院长想看看三个精神病人的恢复情况如何,于是在他们每人面前放了一只小白兔,第一个精神病人坐在小白兔的上面,揪着小白兔的两只耳朵,嘴里嚷着“驾”,院长摇了摇头;第二个人背对着小白兔,拍着它的XXXXX,嘴里说着“给我追”,院长叹了口气;第三个蹲在那里一个劲儿的摸着小白兔,院长看后,满意地点点头,只听他说了一句:“小样的,放你300米,等我擦好车再追你!”院长倒地晕倒……
十五 小白兔和大狗熊两个蹲在树底下拉屎。 大狗熊对小白兔说:你们小白兔虽然好看,可就是麻烦!沾上点脏东西就能看出来,挺恶心的! 小白兔说:瞧你说的!是不是啊! 大狗熊说:可不是么!大狗熊边说边随手抄起小白兔给自己擦了擦XXXXX扬长而去
十六 小白兔和大狗熊走在森林里,不小心踢翻一只壶。 壶里出来一精灵,说可以满足它们各三个愿望。 狗熊说,把它变成世界上最强壮的狗熊。它的愿望实现了。 小白兔说,给它一顶小头盔。它的愿望也实现了。 狗熊说,把它变成世界上最漂亮的狗熊。它的愿望又实现了。 小白兔说,给它一辆自行车。它的愿望又实现了。 狗熊说,把世界上其它的狗熊全变成母狗熊! 小白兔骑上自行车,一边跑一边说,把这只狗熊变成同性恋……
十七
三个小白兔采到一个蘑菇 两个大的让小的去弄一些野菜一起来吃 小的说 我不去 我走了 你们就吃了我的蘑菇了 两个大的说 不会的 放心去把 于是小白兔就去了~~~ 半年过去了 小白兔还没回来 一个大的说 它不回来了 我门吃把 另一个大的说 再等等吧~~~ 一年过去了 小白兔还没回来 两个大的商量 不必等了 我们吃了吧 就在这时 那个小的白兔突然从旁边丛林中跳出来 生气的说 看!我就知道你们要吃我的蘑菇
睁开双眼,显示器开关的蓝色荧光还在闪烁
卡巴斯基终于停止了他四个多小时的扫描
不是很困了,六点多迷迷糊糊的睡去了,累
家里下雪了,中雪,不知道大还是不大
毕竟在人们描述事物的时候都会有不同程度的失真
哈尔滨的冬天竟然没有怎么下雪,只依旧是冷
宿舍终于空了,硬盘时而和着红灯吱吱呀呀的转着
没有雪花飘落的声音,窗外也很寂寥
路灯亮着,没有风,几株柳树傻傻的举着老枝
浪漫在他乡的城市里熄灭了红烛
今夜的她将为谁无眠 1/25/2008 好久没有上过Blog了,好久没有写过东西了
其实在宿舍的日光灯熄灭、整个人蜷缩到那个冷冰冰的被窝里的时候
总是发现自己有好多好多的事情要想,又好多好多的事情可以想
故事、人生、想写的人物纪事,一个漂亮的开头,一个凄美的结局
一段被打击之后的感悟,一种欺骗自己麻木自己的努力
只可惜所有的所有都在第二天早上被冻醒之后烟消云散
伸手摸摸盖在身上的衣服是在床上还是在地上
地上都是水,捞起半潮的羽绒服,转个身,避开刺目的日光灯
把刚才的梦编一个自己的愿意接受的结尾,关联一个吉利点的对应
这时候,昨天过去了,真的就过去了,什么都不剩下,梦想、追求
只剩下一片空白,和机械式的生活。
不写了..
|
|
|
|