C language > Graphics programming

Squeezing some cool from Windows GDI

(1/5) > >>

MrBcx:
Here's a neat graphics demo that I recently converted to BCX BASIC.

I copied BCX's translation into main.c inside a new Pelles C project.

There are a lot of non-Pelles C directives that I left in. The demo compiles with
all the other popular c\c++ compilers too.

The demo is named CARDIOID.  It uses the Windows plain old Gdi for its
graphics, and a bit of geometry and trig.  I also added double buffering (bitblit)
to improve the visual appearance.

It will run to 99.99 iterations and then end or you can end it any time.  There
is no user control - its a simple graphics demo with some pretty colorful effects.

To rebuild, update the Pelles C path in the project options.

Vortex:
Hi MrBcx,

Very nice work.

frankie:
Nice.  :)

Vortex:
Hello MrBcx,


--- Quote from: MrBcx on August 16, 2023, 03:47:52 AM ---The demo compiles with all the other popular c\c++ compilers too.

--- End quote ---

Trying to compile main.c with VS 2019 commandline tools, I receive a lot of error messages.


--- Code: ---cl -c main.c

main.c(238): error C2143: syntax error: missing ')' before '='
main.c(238): error C2072: 'BCX_Form': initialization of a function
main.c(238): error C2059: syntax error: 'type'
main.c(238): error C2059: syntax error: ')'
main.c(239): error C2143: syntax error: missing ')' before '='
main.c(239): error C2072: 'BCX_Printex': initialization of a function
main.c(239): error C2059: syntax error: ')'
main.c(241): error C2143: syntax error: missing ')' before '='
main.c(241): error C2072: 'BCX_Line': initialization of a function
main.c(241): error C2040: 'HDC': 'int' differs in levels of indirection from 'HDC__ *'
main.c(241): error C2059: syntax error: ')'
main.c(242): error C2143: syntax error: missing ')' before '='
main.c(242): error C2072: 'BCX_Circle': initialization of a function
main.c(242): error C2059: syntax error: 'type'
main.c(242): error C2059: syntax error: ')'
main.c(243): error C2143: syntax error: missing ')' before '='
main.c(243): error C2072: 'Center': initialization of a function
main.c(243): error C2040: 'HWND': 'int' differs in levels of indirection from 'HWND__ *'
main.c(243): error C2059: syntax error: ')'
main.c(249): error C2143: syntax error: missing ')' before '='
main.c(249): error C2072: 'instr': initialization of a function
main.c(249): error C2059: syntax error: 'type'
main.c(249): error C2059: syntax error: ')'
main.c(252): error C2143: syntax error: missing ')' before '='
main.c(252): error C2072: 'ModStyle': initialization of a function
main.c(252): warning C4142: 'DWORD': benign redefinition of type
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\minwindef.h(156): note: see declaration of 'DWORD'
main.c(252): error C2370: 'DWORD': redefinition; different storage class
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\minwindef.h(156): note: see declaration of 'DWORD'
main.c(252): error C2370: 'BOOL': redefinition; different storage class
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared\minwindef.h(157): note: see declaration of 'BOOL'
main.c(252): error C2059: syntax error: ')'
main.c(409): error C2198: 'instr': too few arguments for call
main.c(413): error C2198: 'instr': too few arguments for call
main.c(417): error C2198: 'instr': too few arguments for call
main.c(474): warning C4029: declared formal parameter list different from definition
main.c(528): error C2371: 'Center': redefinition; different basic types
main.c(243): note: see declaration of 'Center'
main.c(596): error C2371: 'BCX_Printex': redefinition; different basic types
main.c(239): note: see declaration of 'BCX_Printex'
main.c(628): error C2040: 'BCX_Form': 'HWND (LPCTSTR,int,int,int,int,int,int)' differs in levels of indirection from 'int (LPCTSTR,int)'
main.c(643): warning C4029: declared formal parameter list different from definition
main.c(662): warning C4029: declared formal parameter list different from definition
main.c(677): warning C4029: declared formal parameter list different from definition
main.c(791): warning C4020: 'BCX_Form': too many actual parameters
main.c(791): warning C4047: '=': 'HWND' differs in levels of indirection from 'int'
main.c(794): error C2198: 'Center': too few arguments for call
--- End code ---

MrBcx:
Hi Vortex ... It compiles and runs just fine using MS Visual Studio 2022.

BCX BASIC to C/C++ Translator (c) 1999-2023 by Kevin Diggins
Version 8.0.2 (08/16/2023) Compiled using MS Visual C++ for 64-bit Windows Systems
[Lines In: 123] [Lines Out: 875] [Statements: 92] [Time: 0.03 Sec's]
BCX translated [Cardioid.Bas] to [Cardioid.C] for a C Compiler

**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.0
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
**************************************************************************
MSVC is compiling [ "C:\Bc\Demos\_Other\Cardioid\cardioid" ] as a 64-bit GUI application.

Microsoft (R) C/C++ Optimizing Compiler Version 19.32.31332 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Linking "C:\Bc\Demos\_Other\Cardioid\cardioid"

Microsoft (R) Incremental Linker Version 14.32.31332.0
Copyright (C) Microsoft Corporation.  All rights reserved.

**************************************************************************
MSVC built [ "C:\Bc\Demos\_Other\Cardioid\cardioid".exe ]
**************************************************************************

Below are my MSVC  cl.exe and link.exe command lines that might help you troubleshoot:

cl.exe /std:c++20 /permissive /c /O2 /Gd /W2 /MT -D NTDDI_VERSION=0x0A000000 -D_WIN32_WINNT=0x0A000000 /EHsc /Tp  %1.c

link.exe /RELEASE /MACHINE:X64 /SUBSYSTEM:WINDOWS %1.obj  /OUT:%1.exe

Navigation

[0] Message Index

[#] Next page

Go to full version