请帮助看一下这样的代码注释有那些地方是不好的,需要改进的,多谢
请帮助看一下这样的代码注释有那些地方是不好的,需要改进的,谢谢.
------解决方案--------------------
挺好的,如果注释比较密集,代码的间隔可以放大点,那样更清晰
------解决方案--------------------
看着有些凌乱,参数比较多的函数,要加注释,建议每个参数一行,然后将注释写在每行后面。
------解决方案--------------------
我不知道是不是我独有的注释规则,我是这样的:
void DrawTextString( // 这个函数是干什么的
// 输出字符的最左边
int x
,
// 输出字符的最上边(最右边与最下边分别为屏幕的最右边与最下边)
int y
,
// 输出字符的颜色
D3DXCOLOR color
,
// 要输出的字符
const TCHAR* str
);
// 对于注释,斜杠的后面加一空格
//对于临时注释掉的有效代码,代码前面直接加斜杠
////对于参考代码或相关代码,或之前的错误代码,或近似代码用四个斜杠
/*
整段注释
*/
/*
临时注销整段代码
//*/
------解决方案--------------------
//一个程序有且只有一个cGraphicsLayer object
static cGraphicsLayer* m_pGlobalGLayer;
/*
Copyright 2013 google Inc.
License: GPL
author:linjieligc@qq.com
文件说明: 创建cGraphicsLayer类,初始化DirectX
使用说明:
创建类实例并初始化DirectX
cGraphicsLayer::Create(hWnd,width,height);
//通过Graphics()取得指向cGraphicsLayer实例的指针
//从而使用cGraphicsLayer的各种函数
Graphics()->DrawTextString(x,y,color,str);
Graphics()->Present();*/
#ifndef GRAPHICSLAYER_H_
#define GRAPHICSLAYER_H_
#include<d3d10.h>
#include<d3dx10.h>
#include<list>
#include<string>
using std::wstring;
using std::list;
#include"GameTypes.h"
#include"DxHelper.h"
class cApplication;
class cGraphicsLayer
{
protected:
HWND m_hWnd; //The handle to the main window
ID3D10Device* m_pDevice; //The IDirect3DDevice10 interface
ID3D10Texture2D* m_pBackBuffer; //Pointer to the back buffer
//Pointer to the render target view
ID3D10RenderTargetView* m_pRenderTargetView;
IDXGISwapChain* m_pSwapChain; //Pointer to the swap chain
RECT m_rcScreenRect; //The dimensions of the screen
//设置m_hWnd=hWnd,m_pGlobalGLayer=this,其他成员变量为NULL
//并确保一个applicaion有且只能有一个cGraphicsLayer instantiated
cGraphicsLayer(HWND hWnd/*主窗口句柄*/);
//一个程序有且只有一个cGraphicsLayer object
static cGraphicsLayer* m_pGlobalGLayer;
ID3DX10Font* m_pFont; //The font used for rendering text
ID3DX10Sprite* m_pFontSprite; //Sprites used to hold font characers
ID3D10InfoQueue* m_pMessageQueue; //Queue used to hold messages from D3D
static const UINT m_uiMAX_CHARS_PER_FRAME = 512;
public:
//释放所有com interface,并设置m_pGlobalGLayer=NULL
void DestroyAll();
//释放所有com interface,并设置m_pGlobalGLayer=NULL
~cGraphicsLayer();
//创建IDXGISwapChain,ID3D10Device,ID3D10InfoQueue,ID3D10Texture2D,
//ID3D10RenderTargetView,ID3DX10Font,ID3DX10Sprite,并分别赋值给
//m_pSwapChain,m_pDevice,m_pMessageQueue,m_pBackBuffer,
//m_pRenderTargetView,m_pFont,m_pFontSprite
//另外还设置了target view,view point
void InitD3D(int width/*屏幕宽度*/, int height/*屏幕高度*/,
int bpp/*暂时没有使用*/);
//This function uses Direct3DX to wirte text to the back buffer.
//Its much faster than using the GDI
void DrawTextString(
int x, //输出字符的最左边
int y, //输出字符的最上边(最右边与最下边分别为屏幕的最右边与最下边)
D3DXCOLOR color,//输出字符的颜色
const TCHAR* str);//要输出的字符
//输出所有的debug消息
void DumpMessages();
//Accessor functions
ID3D10Device* GetDevice()
{
return m_pDevice;
}
ID3D10Texture2D* GetBackBuffer()
{
return m_pBackBuffer;
}
//Gets the screen width
int Width() const
{
return m_rcScreenRect.right;
}
//Gets the screen height
int Height() const
{
return m_rcScreenRect.bottom;
}
//将backbuffer的内容呈现给用户,并输出所有debug消息
void Present();
//以colClear所指定的颜色设置target view的初始颜色
void Clear(const float (&colClear)[4]/*数据依次为rgba*/);
static cGraphicsLayer* GetGraphics()
{
return m_pGlobalGLayer;
}
//使用构造函数创建cGraphicsLayer
//使用InitD3D初始化DirectX
static void Create(
HWND hWnd,//handle to the window
short width,//窗口宽度
short height);//窗口高度
};
inline cGraphicsLayer* Graphics()
{
return cGraphicsLayer::GetGraphics();
}
#endif //GRAPHICSLAYER_H_
------解决方案--------------------
挺好的,如果注释比较密集,代码的间隔可以放大点,那样更清晰
------解决方案--------------------
看着有些凌乱,参数比较多的函数,要加注释,建议每个参数一行,然后将注释写在每行后面。
------解决方案--------------------
我不知道是不是我独有的注释规则,我是这样的:
void DrawTextString( // 这个函数是干什么的
// 输出字符的最左边
int x
,
// 输出字符的最上边(最右边与最下边分别为屏幕的最右边与最下边)
int y
,
// 输出字符的颜色
D3DXCOLOR color
,
// 要输出的字符
const TCHAR* str
);
// 对于注释,斜杠的后面加一空格
//对于临时注释掉的有效代码,代码前面直接加斜杠
////对于参考代码或相关代码,或之前的错误代码,或近似代码用四个斜杠
/*
整段注释
*/
/*
临时注销整段代码
//*/
------解决方案--------------------
//一个程序有且只有一个cGraphicsLayer object
static cGraphicsLayer* m_pGlobalGLayer;