2008年11月30日星期日

Qt 及SDL

Qt部分:
可以把 QWidget包成一個QDockWidget的子类,进而加到QDockWidget中,例如:

SDLVideo *SDLVideo_dock = new SDLVideo; 
QDockWidget *dock_4 = new QDockWidget(tr("Media Player of Online Tool of Robotic Experiment"), this); 
dock_4->setWidget(SDLVideo_dock); // 重点:把 QWidget包成一個QDockWidget的子类 
addDockWidget(Qt::LeftDockWidgetArea, dock_4); 
viewMenu->addAction(dock_4->toggleViewAction()); 

再介绍两个有趣的函数:

setAttribute(Qt::WA_PaintOnScreen);//这个函数可以给屏幕截图 
setUpdatesEnabled(false);//可以决定是否对Widget截的图是否可以Update 

SDL部分:

putenv("SDL_VIDEODRIVER=directx"); 

注意:这个函数必须用在SDL_Init();之前才有实际效果。来设置为directx环境。(VC下为了解除编译警告,也可使用SDL_putenv()来代替putenv(),效果都一样。)

以下程序实例--让SDL结合在Qt Widget里,摘自:http://www.guiadohardware.net/comunidade/showthread.php?t=797107
我试了,可以用,但是还不是很完美的解决方案。
如何用SDL创建一个窗口: 一个台湾网友的LinuxGame的博客,中文说明http://otlinux.blogspot.com/2007_12_01_archive.html

英文版http://www.aaroncox.net/tutorials/2dtutorials/sdlwindow.html

如何让SDL嵌入到Qt的Widget里,使用:QWidget::winId()
至今为止,最好的解决方案。例1: http://listas.apesol.org/pipermail/sdl-libsdl.org/2005-September/051604.html

#define NEED_SDL_GETENV 
#include 
//.... 
char variable[256]; 
sprintf(variable, "SDL_WINDOWID=0x%lx", winId()); 
if (SDL_putenv(variable) == -1) 
{ 
// .... 
}

例2:http://stackoverflow.com/questions/118659/how-do-i-use-qt-and-sdl-together

// Set the new video mode with the new window size 
char variable[64]; 
snprintf(variable, sizeof(variable), "SDL_WINDOWID=0x%lx", winId()); 
putenv(variable); 
// ffmpeg is relatively simple. 
// A while back, I used the page below as a reference 
// and coded up a simple app that uses ffmpeg to decode frames 
// and paints them on screen in a QWidget. 

http://www.inb.uni-luebeck.de/~boehme/libavcodec_update.html

2008年11月29日星期六

SDL库在Qt .pro中设定

在.pro 里加上以下的Script:
INCLUDEPATH = "C:\SDL-devel-1.2.13-mingw32\SDL-1.2.13\include\SDL"
win32:LIBS += -L"C:\MinGW\lib" -lmingw32 \
-L"C:\SDL-devel-1.2.13-mingw32\SDL-1.2.13\lib" -lSDLmain -lSDL
注意1: INCLUDEPATH的双引号可加可不加,win32:LIBS的双引号最好加上

2:win32:LIBS加入的顺序是很重要的

3:用 \ 和 / 效果是一样的对于连接

4:不同的文档用 \ 相隔

5:当写-L时,写-lSDLmain而不是libSDLmain.a 等等,注意写的规范性。

举一个实例:让使用Qt的项目(使用MinGW gcc)可以编译SDL_image
1.在.pro中加入
INCLUDEPATH = C:\SDL_image-1.2.7\include
win32:LIBS += C:\SDL_image-1.2.7\lib\SDL_image.lib
2.将C:\SDL_image-1.2.7\lib中的.dll文件拷到C:\WINDOWS\system32里去
3.在所需的C++文件中加入头文件:#include "SDL_image.h"



2008年11月28日星期五

Qt qmake Makefile设置

从Qt提供的许多现存的源程序中找到相关的.pro项目文件,它们是学习qmake 更多技巧的最佳范例。

Makefile -->用 make 来开发和编译程式的确很方便 --> Makefile可以像这样由\".pro\"文件生成 --> qmake -o Makefile hello.pro (使用qmake作为Qt库和Qt所提供的工具的主要连编工具)用qmake 和.pro 文件一起生成 Makefile
--> 只需要写.pro 文件来链接它不同的链接库等等... ...


We will use qmake to build the executable, so we need to write a .pro file:
以下英文简介来自qmake用户手册:
Declaring Other Libraries
If you are using other libraries in your project in addition to those supplied with Qt, you need to specify them in your project file.
The paths that qmake searches for libraries and the specific libraries to link against can be added to the list of values in the LIBS variable. The paths to the libraries themselves can be given, or the familiar Unix-style notation for specifying libraries and paths can be used if preferred.
For example, the following lines show how a library can be specified:
LIBS += -L/usr/local/lib -lmath
The paths containing header files can also be specified in a similar way using the INCLUDEPATH variable.
For example, it is possible to add several paths to be searched for header files:
INCLUDEPATH = c:/msdev/include d:/stl/include


qmake 使用储存在项目(.pro)文件中的信息来决定Makefile文件中该生成什么,简单的说,所谓的设置配置的信息,就是在项目(.pro)文件中设定。 一个基本的项目文件包含关于应用程序的信息,比如,编译应用程序需要哪些文件,并且使用哪些配置设置。 这里是一个简单的示例项目文件:
SOURCES = hello.cpp
HEADERS = hello.h
CONFIG += qt warn_on release
Makefile可以设定使得 Qt Program可以被编译和链接(linken)。
例如:
win32:LIBS = $(QTDIR)/lib/qt-mt230nc.lib \ $(QTDIR)/lib/qtmain.lib
或:
win32:LIBS += C:/DXSDK/Lib/amstrmid.lib \
C:/DXSDK/Lib/d3d8.lib \
C:/DXSDK/Lib/d3d9.lib
不要忘了:路径中是用 / 相连!!.lib之间用 \ 相隔。
进阶阅读:如何用qmake快速生成makefile

2008年11月27日星期四

Qt-Phonon

刚刚发现有一个很好用的工具在Eclipse:Project View --> properties --> Restore from Local History (可以将以前误删的文件找回)
以下是一个德国高手关于Phonon在WinXP的安装的介绍,是我至今看到最好的。阅读时请注意:这个是对于Qt对于Microsoft Visual Studio的,对于Qt和MinGW则无法进行操作,Qt的官方网站上已经有说道,我就是看介绍太不仔细,居然 没看到:Warning: The MinGW version of Qt does not support building the Qt backend. 所以,在这里我用的是MinGW + Qt openSource + Eclipse是无法building Qt backend 的.
以下我摘抄的要点,对于Microsoft Visual Studio的:
Compilation of Phonon under Windows XP

注意:Patch SDKs
Wired but true, the Windows SDK does not compile. It is somehow broken. You need to do the following:
Add the following line
#include "rpcsal.h"
to linenumber 32 in files
C:\Programme\Microsoft SDKs\Windows\v6.1\Include\medparam.h
C:\Programme\Microsoft SDKs\Windows\v6.1\Include\mediaobj.h .pro for qmake:
INCLUDEPATH = C:\DXSDK\Include \ C:\Program Files\Microsoft SDKs\Windows\v6.1\Include
LIBPATH += C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib
产生: phonon.bat以及Configure"%PROGRAMFILES%\Microsoft DirectX SDK (April 2007)\utilities\bin\dx_setenv.cmd"
%PROGRAMFILES%\Microsoft SDKs\Windows\v6.1\Bin\SetEnv.Cmd
The last one should only be necessary if you use the Express Version, but it is no problem if is called anyway
注意:请使用Qt Command Prompt 然后进入Qt的目录执行configure.exe : If your environment is setup correctly, executing configure.exe on your Qt installation should automatically activate Phonon.

2008年11月25日星期二

在Eclipse建立SDL Extension Libraries

在Eclipse建立SDL Extension Libraries (Setting up SDL Extension Libraries in Eclipse)
http://www.libsdl.org/下载 SDL Windows development library
每一个 extension libary 有三个主要部分:

1. The header file.
2. The lib file.
3. The *.dll file(s)

将 header file 存到 MinGW include folder. It should be at C:\MinGW\include\SDL.
将lib file 存到MinGW lib folder. The MinGW lib folder should be at C:\MinGW\lib.
再 提取 *.dll file(s) 到 C:\WINDOWS\SYSTEM32 (This is so whenever you make an SDL extension app, the program will be able to find the *.dll file(s) even if they're is not in the same directory as the *.exe)

但是存放.lib 和头文件的位置也不用和上面所说的一样,但是要记住放置的位置:)


SDL是用C编写的,但是也支持C++,同时其他多种语言,太好了,我们可以用自己熟悉的语言使用它。我在以后的实例中使用C++来使用它。

现在在Eclipse中进行一些设定:
properties --> C/C++ build --> Setting --> GCC Compiler --> Directories --> Include paths (-I) --> 加入所有需要的Include
properties --> C/C++ build --> Setting --> MinGW C Linker --> Libraries --> Include search path (-L) --> 加入所有需要的Library的Path --> 在Libraries (-I)里加入 mingw32 SDLmain SDL 请注意:要依次加入!!

linker的名称为 :
-lmingw32
-lSDLmain
-lSDL

另一个值得注意的点:#include 的写法,因为我在properties --> C/C++ build --> Setting --> GCC Compiler --> Directories --> Include paths 只写了例如:C:\SDL-devel-1.2.13-mingw32

如果使用的是Qt Eclipse Integration,就不需要进行以上操作,只需对.pro文档进行设定,在.pro文档中加入SDL的include和lib名称和路径。

2008年11月23日星期日

实战Qt .ui文档

首先,关于uic的一些小小的点,很有必要知道的:
The uic tool converts xxxx.ui into C++ and puts the result in ui_xxxx.h.
The generated ui_xxxx.h file contains the definition of the Ui::xxxx class, which is a C++ equivalent of the xxxx.ui file.
如果编译出错: launch failed no binaries

解决方法: 在 project-> properties 中把 c/c++ make project 的 binary parse 进行设置到 PE windows parsers
使用Qt Designer Editor生成的example.ui -->其对应的example.cpp 和 example.h 有ui.setupUi(this);
private:
Ui::ExampleToolClass ui;
的文件,其原文档在ui_example.h里可以使用它的一些设定,这个文件由BUILD生成的。
windows的qt里有个uic.exe
qt4
uic xxx.ui -o xxx.h
把UIC.exe和你要转换的xxx.ui文件拷贝到同一目录。
开始菜单,运行CMD
进入uic.exe和xxx.ui的目录,运行以下命令:
uic xxx.ui -o xxx.h 生成.h文件
uic xxx.ui -i xxx.h -o xxx.cpp 生成.cpp文件
uic -o myform.h myform.ui # generate header file
uic -o myform.cpp -impl myform.h myform.ui # generate implementation file
uic -o myformimpl.h -subdecl MyFormImpl myform.h myform.ui # generate subclass header file
uic -o myformimpl.cpp -subimpl MyFormImpl myformimpl.h myform.ui # generate subclass implementation file
如何修改.h文件:但在QT4在Windows下面 -->OpenSource版只有界面设计功能,其它的就沒了--> 用纯代码进行界面设计师必要的,也是非常重要的,QT Designer只是为了加快界面开发。在自己定义的类里加一个Qt Designer里生成的类的成员,並SetupUi()安裝它,所有在Designer里设计不到的部分,在自定义类里进行处理。
看QT Assistant -->QT Designer的用法的那部分帮助。
有两种方法创建GUI 使用 Qt:
使用直接编程法,我个人推荐这种方法。比较容易生成链接,比较容易进行signal and slot的处理。只需建立xxx.h和xxx.cpp文件,无需建立Qt class之类的文件. 
使用Qt Designer: 它会生成ui_xxx程序(会自动生成,或可以用UCI程序生成),可以把它分解成两部分xxx.h和xxx.cpp但是不是那么容易,然后进行编程。

还有一种比较直接的方法,我称其为:"结合使用法",详细见:以下推荐的书的原版35页。

C++ GUI Programming with Qt 4中文版

2008年11月22日星期六

使用 Xilinx ChipScope对FPGA进行调试

If the prblem with your design lies at the tp-level or is fundamentally hardware-related, using ChipScope modules is probably the best way to debug them.

Example:

如何使用 Xilinx ChipScope对FPGA进行调试,具体请看教程
-- Xilinx Chipscope -- Instantiations
chipscope_controller : chipscope_icon
port map (control0 => chipscope_control);

chipscope_logicanalyzer : chipscope_ila_1
port map (clk => clk_lb, -- #
control => chipscope_control,
trig0 => chipscope_trig0);

-- Trigger
-- chipscope_trig0 <= (not ncore_ta) and (ncore_rw);
-- here:
-- chipscope_trig0 <= cluster_system_chipscope_trig_top;
-------------------------------------------------------

-- Xilinx Chipscope
signal chipscope_trig_top_int : std_logic_vector(0 downto 0);
-------------------------------------------------------
chipscope_trig_top_int(0) <= ((not ncore_ta) and (ncore_r_w)); -- #
chipscope_trig_top <= chipscope_trig_top_int;
逻辑分析仪Xilinx ChipScope的产生有两种方法:

Core Generator
(核产生器): 产生内核,将这些内核例化后添加到原设计文件,最后综合,实现,下载。
Core Inserter(核插入器):不需要修改原文件,它是将生成的内核添加到综合后的网表文件中.

Core Inserter 的流程为:

1)的 RTL 综合成 Netlist

2)调用 Core Inserter 插入逻辑分析仪;

3)布置和布局;

4)产生 bit 文件下载验证。


http://www.stanford.edu/class/ee108a/resources/documentation/chipscope_tutorial.pdf

这是一个很好的简单教程

基本步骤是:
  1. Generationg ChipScope Modules
  2. Incorporating and Instantiating the ChipScope Modules
  3. Connecting the ChipScope Modules
  4. Synthesizing, Implementing, and Running Your Design
  5. Using ChipScope Analyzer

2008年11月21日星期五

使用Qt Eclipse integration加文件到项目里,资源管理,项目管理

加文件到项目里Adding Files to the Project
要增加文件到在Eclipse的一个Qt项目,有二步是必要。首先,文件必须增加到工作区,并且第二,文件必须增加到.pro文件。如果你想要增加一个新的源文件到你的项目,File|New|Source File wizard 和enter 文件名。 Source 文件夹线编辑指定文件将增加的工作区项目。在点击结束以后,项目范围选择器对话框将出现。这对话框显示项目的.pro文件的所有被定义的范围,并且文件可以增加的variable 。在源文件情况下, “源文件”variable 和“标头文件”variable 被显示。 选择应该插入源文件的范围然后点击OK。现在,新的文件是a)增加到工作区和b)被添附到“源文件”variable在.pro文件里。 因为改变了.pro文件,它在编辑被打开并且被标记以被修改。 因此,记住在开始build之前保存.pro文件。
Managing Resources资源管理
要增加新的资源resources,你必须首先创造一个新的.qrc文件。打开File|New|Other... dialog,选择从Qt文件夹里Qt资源文件项目,并且点击Next。 新创建的.qrc文件将被显示在Eclipse上。.qrc文件只包含称/new/prefix1的前缀。你能增加资源在那前缀之下通过点击Add。当稍后关于资源从Qt代码来时,你必须加在前面前缀文件名加在冒号(即, :/new/prefix1/print.bmp)。 对于增加新的前缀,点击在增加按钮的箭头,并且选择Add前缀。 前缀的名字和资源的别名可以更改 with the line edits 在资源视图之下。

项目管理
使用.pro File Editor可以很轻松的利用它所提供的GUI对Project进行管理和改变,在Qt中这是一个很实用的技巧。
详细的例子请:如何进行Project管理


Qt Designer Editor也是很有用的程序,我们可以用它来设计GUI,例如,我们可以使用它改变字的颜色:在 Qt Designer Editor里: Display Widgets --> Label --> Property --> Point Size, text (改名称和大小), 在版上点Label按鼠标右键 --> change rich text --> 可改字的颜色。


2008年11月20日星期四

VHDL设计在FPGA模块测试 & VDHL极限编程结合FPGA实物仿真

例如 先进行5 Port original Switch-Box Testing在这个设计中只该变测试接口add Local Bus Interface, add N_core_Address测试接口,其他保持不变。
the Change for ISE Synthezise:
  1. add: library ethernet_lib;use ethernet_lib.all; in eth_controller.vhd.
  2. add: \hardware\assists : av_hw_acc, IP_header_check
  3. add: \hardware\building_blocks : cc_hw_acc, encoder
  4. in ISE: Sythesize properties: Veliog file path: --> ethenet Path
  5. use the new memory_interface.vhd and do some change to the ncore_wb.vhd: for example CPU_ID
  6. add all CoreGen file to the ISE-directory
  7. ISE libraries: change eth_port.vhd to ETHERNET.lib, change pe_cluster.vhd to URAT.lib
以上的内容对于读者并不重要,我只是记下来提醒自己:正确设置ISE是很重要,也是一点点学问和经验,以上例子表明,进行一个很简单的综合,在前期就要进行多达7步的搭配工作。测试常常需要很多不同的技巧,我这里是用XILINX CoreGenerator 生成储存文档,并和VHDL文件在ISE里进行综合,然后产生具有储存文档所描述功能的Bitstream。有时间的话,我将对XILINX CoreGenerator的使用进行说明。

这里所谓的"VDHL极限编程结合FPGA实物仿真":就是利用eXtreme Programming的一部分思想进行VHDL编程。极限编程:从最简单的解决方式入手再通过不断重构达到更好的结果。这种方法与传统系统开发方式的不同之处在于,它只关注于对当前的需求来进行设计、编码,而不去理会明天、下周或者下个月会出现的需求。
具体步骤:
  1. VHDL小系统的模拟(例:我的项目中:使用只有3个Ports的Switch Box系统在ModelSim进行模拟,这样可以提高模拟效率和速度)
  2. FPGA大系统实物仿真(例:我的项目中:使用有5个Ports的Switch Box的原始系统在ISE进行综合,这样可以保证综合的正确性)
  3. 在VHDL小系统的模拟验证正确的设计,直接放入大的系统,直接进行ISE综合,但是要仔细嵌入新的设计。
  4. 重复以上步骤。

2008年11月19日星期三

使用Eclipes开始第一个Qt例程

首先注意:可以新建一个WORKSPACE因为,Eclipse对于一个Project都需要一个新的WORKSPACE这样就可以把这个Project的所有的东西放在里面,当新建一个WORKSPACE可能要新设置Qt的位置。
先生成一个Qt应用框架
调用New Project dialog in Eclipse --> 点Qt folder --> Qt Gui Project --> 点击 Next -->输入 "AddressBook" 到 Project Name field (对于 "AddressBook" 例子里) --> 点Finish.
当Eclipse 发现 Qt 的位置, the project 这时可以被编译. -->进入 Project menu --> Build Project.
现在可以启用"AddressBook" application,在"AddressBook" project in the "C/C++ Projects" view里, 选 Run|Open Run Dialog... dialog 然后双击C/C++ Local Application item 用于产生一个新的RUN配置。最后 click the Run 按钮。
然后加入构件(Adding the Widgets)
展开 Qt Designer, 双击 addressbook.ui 文件。
先让Qt C++ Widget Box 可视:Window --> Show View --> Other --> Qt --> Qt C++ Widget Box 可让Qt C++ Widget Box出现在View里
开始先见到 QListWidget。 展开 Qt C++ Widget Box, 然后点击 List Widget subitem 并将它拖动到form的左上角. Qt C++ Property Editor (Window|Show View|Qt C++ Property Editor) 将会展示QListWidget的属性.使用property editor, 将objectName property 设为 "addressList".
现在可以试着插入Add and Delete buttons. 在 Qt C++ Widget Box and 拖动两个 Push Buttons 到form的右上角. 将 buttons 改名为 "addButton" and "deleteButton", 将它们的text property(文字属性)设为 "Add" and "Delete"。
哈哈很简单吧。现在已经完成了一个小的widget。

接下来可以看详细的教程.试着完成后面几步。

我的常用的免费软件


几年没有用过盗版软件了,如果要使用一些工具软件,我使用远程登入学校的实验室的机器使用正版,虽然有时比较不方便,但是支持正版人人有责。
在我的古董笔记本里除了(WinXP和Linux)外,只有免费的软件,以下是我常用的免费软件,都很不错。
Firefox mit Google Toolbar: with AddOn -- Tab Kit (Tab Trees), Adblock Plus, Clear Cache Button, Flash Got, Java Quick Start, NoScript, ThunderExtension, google notebook addon
RealPlayer, VLC mediaplayer, quick time, 酷狗音乐:
Google Pingyin,及Google提供的大部分软件,Google Docs 强烈推荐:

Adobe Reader:
MSN:
Notepad++, SVN, Eclipse:
avira antivirus ,CCclean:
HD Tune, SpeedSwitchXP:
NoMachine NX:
WinRAR:
VoipDiscount:
迅雷:
桌面词典 有道

成功生成的 Bitstream 当下载到FPGA时,出错的原因及解决方法

成功生成的 Bitstream 当下载到FPGA时,出错
这很令人愤怒。如果一个大的系统通过 ISE 两个小时以上的综合。BITSTREAM 成功生成了,但下载到 FPGA 时却报错。以下是两个不同的报错。
Attemp to Download full Bitstream
Checking Local 1 Range/Remap Register............Success
FPGA-Erase complete
Startsequenz found, starting programming.......
Preparing for Interrupt..........................Success
ERROR ! Done timeout!
Init is LOW, but should be HIGH, this could indicate a CRC-error

Attemp to Download full Bitstream .
Checking Local 1 Range/Remap Register............Success
ERROR !
Init timeout

我们先讨论其产生原因。
会发生这种情况,常常是我生成2个Bitstream并且分别下载到相邻的FPGA上。这两个Bitstream可以单独放置在FPGA上毫无问题,但是就是不可以分别下载到相邻的 FPGA 上(已经通过多次实验证明),但是通常我需要这两个FPGA模块进行通信交流。

产生原因可能有2个:可能是在LINUX的机器上,不同的时间,综合ISE工具产生的结果是不同的。这个看是很荒谬的原因是我的导师告诉我的,他有多次经历。我在昨天也做了实验,同样一个VHDL设计在不同的时段(不同的LINUX机器)进行综合,新的Bitstream就可以用了。
另一个原因是:可能FPGA的模块的输出和输入没有正确的MAP & ROUTING。一直两个FPGA模块无法对应上。

解决方法:
目前只能进行多次综合,在不同的时段或使用不同的LINUX综合机器。
新的解决方法,如果发现我将在后续发布。
最新的解决方法:
1.请查看ise Project里的FPGA constrain文档是否有正确放置在top 文档下。
2.有时候要先删除旧的FPGA constrain文档,然后再加上一遍,这可能是ise的bug吧,我的导师告诉我的。
3.如果可以的话,请删除和你Project无关的vhd或verilog文档,它们可能会对你的综合产生影响。

开篇 and 安装Qt

因为我的Diplomarbeit需要设计一个软件,今后的一系列文章将分享软件设计过程中的一些心得,由于我是学电子的,对软件设计及编程水平不高,如果文章有错误,请读者大方指出。
我做的软件是 Online Analysis Tool of Robotic Experiment, 也就是机器人实验的在线分析工具,简称暂时为:OATRE

因为要使用Qt, 首先介绍如何安装Qt:
部分翻译来自:
http://labs.trolltech.com/blogs/2007/07/11/develop-qt-applications-in-eclipse/
首先必须安装下列的程序 Download and install the following ingredients:

然后通过 Qt Eclipse Integration --> Start Eclipse with MinGW 启动。
打开 Eclipse 的 HELP 点击 Qt Development User Guide 然后 进入 Getting Started试着开始执行第一个例子。 New Project --> Qt folder --> Qt Gui Project --> Next 或者可以改一些设定。
注意:在 C/C++ Projects View 里点选这个Project 右键鼠标--> Properties 检查是否正确设定 Qt Properties --> Use Qt Version: 系统里当前的Qt 版本。
Window --> Show View --> Other --> Qt --> Qt C++ Widget Box 可让Qt C++ Widget Box出现在View里,然后就可以方便地使用Qt C++ Widget Box。

2008年11月18日星期二

如何让SDL窗口嵌入Qt窗口

先简单介绍一下SDL:

SDL(Simple DirectMedia Layer)是一套开放原始码的跨平台多媒体开发函式库,使用C语言写成。SDL提供了数种控制图像、声音、输出入的函式,让开发者只要用相同或是相似的程式码就可以开发出跨多个平台(Linux、Windows、Mac OS X等)的应用软体。目前SDL多用于开发游戏、模拟器、媒体播放器等多媒体应用领域。
虽然SDL时常被比较为‘跨平台的DirectX’,然而事实上SDL是定位成以精简的方式来完成基础的功能,它大幅度简化了控制图像、声音、输出入等工作所需撰写的程式码。但更高阶的绘图功能或是音效功能则需搭配OpenGL和OpenAL等API来达成。另外它本身也没有方便建立GUI的函式。

但是如何让SDL窗口嵌入Qt的Widget里(render videos, audioes and images under GUI(made of Qt) using SDL. The sdl screen must be successfully integrated into qt screen.) ?
(Implement SDL in a QT widget-- how to integrate SDL into Qt? )
有两种方法用于解决这个问题,一个是间接法如 solution 1 ,一个是直接法如 solution 2. 以下是从网上收集的说明。

Solution 1: Using a seperate thread for rendering:

The easiest and sanest solution would be to decouple both parts. So that SDL and Qt run in separate processes and have them use some kind of messaging to communicate. SDL can be rendered into borderless window and the editor sends commands via messages.

using a seperate thread for rendering.
This thread could run on its own in the background and you simply could use your Qt-buttons to stop/pause/resume the thread.

If you want your SDL-window to react when a real key is pressed, it would be a viable solution to simulate key events from Qt.

If you want to just signal the SDL-code in some way I'd suggest using custom events (SDL_UserEvent).
For example, do something like this:

  1. Start App and open Qt-Window
  2. Initialize SDL and open output window
  3. Create thread that updates SDL-Window waits for some signal to stop/pause/resume or for xx seconds
  4. Use the SLOTs called by your Qt-Buttons to signal the thread to stop/pause/resume (using Key- or UserEvents? or using flags being set by Qt's main-thread) [/list=1]
Solusion 2: Direct way to integrate SDL into Qt:

put the SDL overlay window on the top of Qt window by using the following 3 steps.
1) create SDL window according to the size of Qt window.
2) create SDL window without frame (SDL_NOFRAME).
3) move SDL window based on the top-right coop. of SDL window (xMoveWindow())

Following functions from SDL are mainly used,
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);
p_container->embed(info.info.x11.wmwindow, false).

链接集合:OpenGL,Ffmpeg等等

习Qt除了装软件还要准备一两本书。我推荐C++ GUI Programming with Qt4, 在网上甚至可以收到它的PDF版。http://www.qiliang.net/qt/index.html Qt参考文档,这个网站也是很值得推荐的,它有一个很热心的中国工程师建立的,内容非常实用,中文资料的好处在于我们可以非常快速的阅读和检索我们所需要的资料。
关于 Qt设计器 部分很值得一读。
Qt设计器是用来设计和实现用户界面并能够在多平台下使用的一种工具。Qt设计器可以使用户界面设计实验变得简单。在任何时候你可以要求所生成的代码去重建Qt设计器产生的用户界面文件,并可以根据你的喜好来改变你的设计。
当然的trolltech 上提供的资料是最丰富的:http://trolltech.com/ 很适合进阶阅读。

OpenGL(全写Open Graphics Library)是个定义了一个跨程式语言、跨平台的编程接口的规格, 为三维绘图提供的标准应用编程接口。OpenGL处理的仅仅是三维绘图方面,而很少或是根本不提供图形用户界面编程方面的支持。OpenGL 的 GUI 必须由其它工具包创建,比如Qt。Qt的OpenGL模块使在Qt应用程序中使用OpenGL变的更加容易。它提供了一个OpenGL的部件类,这个部件类除了打开一个OpenGL显示缓冲,利用这个缓冲使用OpenGL应用编程接口来提供内容外,能像其它Qt部件那样的使用。

Starting out with OpenGL 2.1: 这是一个简单的 study guide.

QGLWidget

在Qt中OpenGL提供支持的类为:

  • QGLWidget:一个容易使用的Qt部件,它提供了OpenGL场景。
  • QGLContext:封装了OpenGL提供的上下文。
  • QGLFormat:对于一个给定的上下文,指定特定的显示模式。
  • QGLColormap:在GL-index中处理编入索引的colormaps。
FFmpeg是一个免费开放原码 的软体,可以执行音讯和视讯多种格式的的录影、转档、串流功能,包含了libavcodec ─这是一个用于多个专案中音讯和视讯的解码器函式库,以及 libavformat ——一个音讯与视讯格式转换函式库。FFmpeg is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library. FFmpeg is developed under Linux, but it can compiled under most operating systems, including Windows.
视频技术论坛 » FFMPEG工程组
FFMPEG参数说明
: http://leezen.blogbus.com/logs/19276689.html
ffmpeg使用说明 http://blog.chinaunix.net/u/16166/showart_239248.html
An ffmpeg and SDL Tutorial

ffdshow is a media decoder and encoder mainly used for the fast and high-quality decoding of video in the MPEG-4 ASP (e.g. encoded with DivX, Xvid or FFmpeg MPEG-4) and AVC (H.264) formats, but supporting numerous other video and audio formats as well. It is free software released under the GPL license, runs on Windows and is implemented as a DirectShow and VFW decoding filter.

Xvid(旧称为XviD)是一个开放原始码的MPEG-4视频编解码器,它是基于OpenDivX而编写的。XviD是最新的MPEG-4 codec,而且是第一个真正开放源代码的,一旦完成就会通过GPL协议发布.
http://www.xvid.org/
Xvid in Baidu

Notepad++ and 一些杂谈

编 VHDL 我们研究所习惯用 Notepad++ 一是因为免费开源,二是的确很好用。它有一些有用的技巧如,Clone to another View, 在文档TAB上右击鼠标,点可以分屏幕进行编程,我一直使用分屏幕进行编程,很方便,便于调试。ctrl + shift + del : 整行删除。shift + TAB : TAB 消除。ctrl + shift + 上或下: 整行向上或向下移动。ctrl + d : 整行copy。

顺便谈谈提高使用工作的效率的方法,
1. linux下使用 bash 脚本语言编程. windows里使用批处理文件bat是很有用的。
2. 在工作是扔掉你的鼠标的确也是一个很不错的方法,但是要记住一些快捷键。

其实我根本记不住很多快捷键和一些命令,让我想一想,我能记住的Windows的快捷键和命令大概如下:
再多也记不住了,要google一下:) 。
Command Prompt: 看系统信息:systeminfo组合键:Ctrl + Tab,Windows键 + Tab 键(可以使任务栏图标进行切换),Windows键 +d(显示出电脑桌面),Windows键 + e, Windows键 + r
常用的windows run 命令:
XP的启动项命令:MSCONFIG
打开屏幕键盘:osk
系统配置实用程序:Msconfig.exe
简易widnows media player:mplayer2
远程桌面连接:mstsc
注册表 :regedit.exe
组策略结果集 :rsop.msc
注册表编辑器:regedt32
linux的命令,我只能记得一些常用的,常常要使用man命令。
对我来说最重要的命令就是man :)
man [-k] [command]
man intro
man bash info [command]
help [-s] [command]
参数:
-s: 用法摘要
-k: 在所有的man文档和简介中查找符合条件的命令

使用 local bus slave in FPGA 用于检测 VHDL Design

对FPGA进行测常常是一件很麻烦的工作。
这里有我最近的设计,例:
通过不同的从LOCAL BUS给定的地址可以从FPGA中很方便地读出所需要的测试数据。


status_multiplexer: process (I_ADR_test, DEBUG_PORT) is
begin
  case conv_integer(I_ADR_test)*4 is
  when 0 => I_DATA_IN_test_fpga2pc <= DEBUG_PORT(31 downto 0);
  when
4 => I_DATA_IN_test_fpga2pc <= DEBUG_PORT(63 downto 32);
  when
8 => I_DATA_IN_test_fpga2pc <= DEBUG_PORT(95 downto 64);
  when
12 => I_DATA_IN_test_fpga2pc<= DEBUG_PORT(127 downto 96); -- = 0xC
  when others
=> I_DATA_IN_test_fpga2pc <= "10101010101010101010101010101010";
end case;
end process
;


这里只用了一个很简单的multiplexer。
完成了对多个数据的测试。这个设计对于读取时地址资源稀少的 LOCAL BUS 设计很有帮助。可以只用一个 LOCAL BUS 但是可以读出不同的测试数据(在不同的时间)。我们只要给定 LOCAL BUS 的值 在本例中,给定 60004,就可以读出 DEBUG_PORT(63 downto 32)的数据。

Hanyi on ET

在这个博客我将和大家分享电子技术学习和其他一些有趣的事物.