游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3524|回复: 5

高手和大虾来回答!!!

[复制链接]

1

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
发表于 2006-3-30 14:26:00 | 显示全部楼层 |阅读模式
我用Delphi + DirectDraw编程时遇到一个问题,如下:
C++语言的程序为:
  DDSURFACEDESC2 ddsd;
   ......
   int mempitch = ddsd.lPitch;
   UCHAR * video_buffer = ddsd.lpSurface;
   // plot 1000 random pixels with random colors on the primary surface,
   // they will be instantly visible
   for (int index=0; index<1000; index++)
     {
       UCHAR color = rand() % 256;
       int x = rand() % 640;
       int y = rand() % 480;
       // plot the pixel
       video_buffer[x+y*mempitch] = color;<----------------------------问题部分???
     } // end for index
   其中lpSurface是一个指针,怎样才能把标记的部分变为Pascal语言呢? [em7] [em7] [em7] [em24] [em24] [em24]

9

主题

61

帖子

65

积分

注册会员

Rank: 2

积分
65
发表于 2006-3-31 23:38:00 | 显示全部楼层

Re:高手和大虾来回答!!!

Pvideo_buffer: Pointer;

Pvideo_buffer:=Pointer(x+y*mempitch);
Pvideo_buffer^:=color

1

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
 楼主| 发表于 2006-4-1 14:38:00 | 显示全部楼层

Re:高手和大虾来回答!!!

不对啊!!!

1

主题

14

帖子

14

积分

新手上路

Rank: 1

积分
14
发表于 2006-4-1 22:44:00 | 显示全部楼层

Re:高手和大虾来回答!!!

var  ddsdDSURFACEDESC2 ;
   ......
     mempitch,index,x,y:Integer;
           Color:Byte;
video_bufferbyteArray;

  mempitch:= ddsd.lPitch;
   video_buffer:=Pointer(ddsd.lpSurface);

   for Index = 0 to 999 do
      Begin
       Color:=Random(256);
        x := Random(640);
        y := Random(480);
       // plot the pixel
       video_buffer[x+y*mempitch] := color;
      End;

这是对一个640x480x256色t的表面写1000个随机位置随机颜色的点

1

主题

7

帖子

7

积分

新手上路

Rank: 1

积分
7
 楼主| 发表于 2006-4-2 13:16:00 | 显示全部楼层

Re:高手和大虾来回答!!!

你的方法Delphi可以编译,但单独运行时提示( Invalid variant type conversion),还是没效果啊!!!

16

主题

160

帖子

176

积分

注册会员

Rank: 2

积分
176
QQ
发表于 2006-4-3 14:18:00 | 显示全部楼层

Re:高手和大虾来回答!!!

获取LPSURFACE前先要LOCK住表面
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-24 02:38

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表