Code: Select all
main.bas(17) error 73: Array access, index expected, before ')' in 'StretchDIBits(hDC,0,0,ScreenX,ScreenY,0,0,ResX,ResY,pixel,@bmi,0,SRCCOPY)'
the code in freebasic is this
Code: Select all
#include "windows.bi"
#define ResX 256
#define ResY 192
Dim As MSG msg
Dim As Integer
static As Integer pixel(ResX*ResY)
static As BITMAPINFO bmi = Type(sizeof(BITMAPINFOHEADER),ResX,ResY,1,32)
Dim As HWND hWnd = CreateWindowEx(0,"edit",0,(WS_OVERLAPPEDWINDOW Or WS_SYSMENU) - (WS_THICKFRAME) Or WS_VISIBLE,200,200,ResX,ResY,0,0,0,0)
Dim As HDC hDC = GetDC(hWnd)
of
PeekMessage(@msg,0,0,0,PM_REMOVE)
Dim As Integer ScreenX = GetSystemMetrics(SM_CXSCREEN)
Dim As Integer ScreenY = GetSystemMetrics(SM_CYSCREEN)
StretchDIBits(hDC,0,0,ScreenX,ScreenY,0,0,ResX,ResY,pixel,@bmi,0,SRCCOPY)
SwapBuffers(hDC)
Dim As Integer t = GetTickCount()
for i = 0 To ResX*ResY
pixel(i) = i + t
Next
loop
ExitProcess(0)
Code: Select all
#include <windows.h>
#define ResX 256
#define ResY 192
int main(void) {
// required data
static int pixel[ResX*ResY];
static BITMAPINFO bmi = {sizeof(BITMAPINFOHEADER),ResX,ResY,1,32};
// window creation
HWND hWnd = CreateWindowEx(0,"edit",0,(WS_OVERLAPPEDWINDOW | WS_SYSMENU) - (WS_THICKFRAME) | WS_VISIBLE,200,200,ResX,ResY,0,0,0,0);
HDC hDC = GetDC(hWnd);
ShowCursor(FALSE);
// main loop
for (MSG msg; msg.message != WM_KEYDOWN; PeekMessage(&msg,0,0,0,PM_REMOVE)) {
// screen blitting
int ScreenX = GetSystemMetrics(SM_CXSCREEN);
int ScreenY = GetSystemMetrics(SM_CYSCREEN);
StretchDIBits(hDC,0,0,ScreenX,ScreenY,0,0,ResX,ResY,pixel,&bmi,0,SRCCOPY);
SwapBuffers(hDC);
// pixel pushing
int t = GetTickCount();
for (int i = 0; i < ResX*ResY; i++) pixel[i] = i + t;
}
ExitProcess(0);
return 0;
}