News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Strobe effect

Started by Vlad417, June 05, 2007, 08:08:37 PM

Previous topic - Next topic

Vlad417

I am a beginner programmer and was curious, what would source for a simple strobe program look like.  I know the idea behind it, but I don't have enough knowledge on the functions to be used. Thank you in advance

TDragon

#1
A program for what kind of device? Microcontroller? Serial or other data cable controlling a strobe device from a PC? A PC itself?
What kind of strobe effect? Flashing the PC screen? Sending electricity to a strobe light bulb?
If on a PC, for what OS? Windows? Linux? Mac?
What programming languages are available for your preferred platform? What compilers exist for it?
Do you have access to system APIs such as Win32?
How about DirectX or OpenGL?
Can you use middleware like SDL or Allegro? Should you?

Edit:
In the spirit of being helpful and trying to answer the question, here's a program for flashing the PC screen, valid as C or C++, using the Allegro library, for any OS that Allegro supports. It alternates the screen between white and black on an evenly-split 30-millisecond period.

#include <allegro.h>

int main()
{
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0);
while (!key[KEY_ESC])
{
vsync();
rectfill(screen, 0, 0, 640, 480, makecol(255, 255, 255));
rest(15);
vsync();
rectfill(screen, 0, 0, 640, 480, makecol(0, 0, 0));
rest(15);
}
return 0;
}
END_OF_MAIN()


Final edit:
The C::B forums are not intended to be a place to post questions related to programming in general, but rather only questions that directly relate to the use of the Code::Blocks program itself. The text "This is NOT a general programming board" should be a good indicator of that. In the future, it would be better to post questions like this in a forum specifically dedicated to that purpose, such as the forums at GameDev.net.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

Compiling: C:\cpp_files\strobe.cpp
Linking console executable: C:\cpp_files\strobe.exe
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x27): undefined reference to `_install_allegro_version_check'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x2c): undefined reference to `install_keyboard'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x58): undefined reference to `set_gfx_mode'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x5d): undefined reference to `_imp__key'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x6e): undefined reference to `vsync'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x8a): undefined reference to `makecol'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0xb3): undefined reference to `_imp__screen'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0xc9): undefined reference to `rest'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0xce): undefined reference to `vsync'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0xea): undefined reference to `makecol'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x113): undefined reference to `_imp__screen'
C:\cpp_files\strobe.o:strobe.cpp:(.text+0x129): undefined reference to `rest'
C:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings



thats what i get when i compile it. i hav installed allegro, allegro supplement, allegrofont, and alegrogl packages into code::blocks

TDragon

All you're missing is a command to link with the Allegro library file. Add "alleg" to the "Link libraries" list in your project's linker settings. (If the file "liballeg.a" can't be found, you'll need to add the path to it in the Linker search directories.)
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

Compiling: C:\cpp_files\strobe.cpp
Linking console executable: C:\cpp_files\strobe.exe
C:\Program Files\CodeBlocks\lib/libmingw32.a(main.o):main.c:(.text+0x106): undefined reference to `WinMain@16'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings


once again not making an executable

darthdespotism

Hast du auch ein Konsolenprojekt erstellt?

Sieht mir fast so aus als wäre das ein Win32-Projekt. Dann brauchst du statt der main() eine WinMain()

MortenMacFly

Quote from: darthdespotism on June 05, 2007, 10:56:42 PM
Hast du auch ein Konsolenprojekt erstellt?
Please, english only!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Vlad417

Was ist ein Konsolenprojekt?

Ich nicht weisse ob oder nicht es ist ein Win32-Projekt oder ein KonsoleProject.
Ich wille ein Konsoleproject, Ich denke.

tut mir leid fur das schlechten Deustch.

TDragon

Allegro's END_OF_MAIN() macro allows you to use main() instead of WinMain(), but you do still need to select "GUI application" as your target's type in the Build targets tab of your project properties.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

it compiles but when i run the .exe i get this:


"This application has failed to start because alleg42.dll was not found.  Re-installing the application may fix this problem"

after i had that alert box i reinstalled code::blocks and the allegro package. i keep getting the message

NOTE: For some reason Code::Block is not letting me into the project properties. when i click on them nothing loads at all. nothing changes.

TDragon

The application doesn't know where to find alleg42.dll. Find it, and put it in the same folder as the .exe.
[url="https://jmeubank.github.io/tdm-gcc/"]https://jmeubank.github.io/tdm-gcc/[/url] - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

works perfectly!

i just added a quick console prompt to ask for user's frequency
THANKS TDragon!