User forums > General (but related to Code::Blocks)

Strobe effect

(1/3) > >>

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:
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.

--- Code: ---#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()

--- End code ---

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.

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.)

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

Navigation

[0] Message Index

[#] Next page

Go to full version