Author Topic: Strobe effect  (Read 10257 times)

Vlad417

  • Guest
Strobe effect
« on: June 05, 2007, 08:08:37 pm »
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

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Strobe effect
« Reply #1 on: June 05, 2007, 08:16:22 pm »
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()

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.
« Last Edit: June 05, 2007, 08:44:10 pm by TDragon »
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

  • Guest
Re: Strobe effect
« Reply #2 on: June 05, 2007, 08:47:10 pm »
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

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Strobe effect
« Reply #3 on: June 05, 2007, 09:21:51 pm »
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.)
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

  • Guest
Re: Strobe effect
« Reply #4 on: June 05, 2007, 10:47:30 pm »
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

Offline darthdespotism

  • Almost regular
  • **
  • Posts: 163
    • Coder's Nemesis
Re: Strobe effect
« Reply #5 on: June 05, 2007, 10:56:42 pm »
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()

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9699
Re: Strobe effect
« Reply #6 on: June 05, 2007, 11:07:20 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: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Vlad417

  • Guest
Re: Strobe effect
« Reply #7 on: June 05, 2007, 11:12:27 pm »
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.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Strobe effect
« Reply #8 on: June 05, 2007, 11:25:48 pm »
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.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

  • Guest
Re: Strobe effect
« Reply #9 on: June 05, 2007, 11:50:58 pm »
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.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: Strobe effect
« Reply #10 on: June 06, 2007, 12:45:43 am »
The application doesn't know where to find alleg42.dll. Find it, and put it in the same folder as the .exe.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Vlad417

  • Guest
Re: Strobe effect
« Reply #11 on: June 06, 2007, 10:30:56 pm »
works perfectly!

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