Initial import
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1101 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
d773b106be
commit
3a81c0cfab
14 changed files with 850 additions and 0 deletions
59
CSFML/xcode/templates/CSFML Window-based Application/main.c
Normal file
59
CSFML/xcode/templates/CSFML Window-based Application/main.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Entry point of application
|
||||
///
|
||||
/// \return Application exit code
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
// Create main window
|
||||
sfVideoMode mode = {640, 480, 32};
|
||||
sfWindowSettings settings = {24, 8, 0};
|
||||
sfWindow *App = sfWindow_Create (mode, "CSFML Window", sfClose, settings);
|
||||
|
||||
// Start game loop
|
||||
while (sfWindow_IsOpened(App))
|
||||
{
|
||||
// Process events
|
||||
sfEvent Event;
|
||||
while (sfWindow_GetEvent(App, &Event))
|
||||
{
|
||||
// Close window : exit
|
||||
if (Event.Type == sfEvtClosed)
|
||||
sfWindow_Close(App);
|
||||
|
||||
// Escape key : exit
|
||||
if ((Event.Type == sfEvtKeyPressed) && (Event.Key.Code == sfKeyEscape))
|
||||
sfWindow_Close(App);
|
||||
|
||||
// Resize event : adjust viewport
|
||||
if (Event.Type == sfEvtResized)
|
||||
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
|
||||
}
|
||||
|
||||
// Set the active window before using OpenGL commands
|
||||
// It's useless here because active window is always the same,
|
||||
// but don't forget it if you use multiple windows or controls
|
||||
sfWindow_SetActive(App, sfTrue);
|
||||
|
||||
// Clear color buffer
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// Your drawing here...
|
||||
|
||||
// Finally, display rendered frame on screen
|
||||
sfWindow_Display(App);
|
||||
}
|
||||
|
||||
// Destroy our window
|
||||
sfWindow_Destroy(App);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue