gKit2 light
Loading...
Searching...
No Matches
tuto1.cpp File Reference

creation d'une application vide. affiche une fenetre vide / noire. More...

#include <stdio.h>
#include "window.h"

Go to the source code of this file.

Functions

int init ()
int draw ()
int quit ()
int main (int argc, char **argv)

Detailed Description

creation d'une application vide. affiche une fenetre vide / noire.

Definition in file tuto1.cpp.

Function Documentation

◆ init()

int init ( )

Definition at line 22 of file tuto1.cpp.

23{
24 return 0; // renvoyer 0 ras, pas d'erreur, sinon renvoyer -1
25}

◆ draw()

int draw ( void )

Definition at line 28 of file tuto1.cpp.

29{
30 return 1; // on continue, renvoyer 0 pour sortir de l'application
31}

◆ quit()

int quit ( )

Definition at line 34 of file tuto1.cpp.

35{
36 return 0; // ras, pas d'erreur
37}

◆ main()

int main ( int argc,
char ** argv )

Definition at line 40 of file tuto1.cpp.

41{
42 // etape 1 : creer la fenetre
43 Window window= create_window(1024, 640);
44 if(window == NULL)
45 return 1; // erreur lors de la creation de la fenetre ou de l'init de sdl2
46
47 // etape 2 : creer un contexte opengl pour pouvoir dessiner
48 Context context= create_context(window);
49 if(context == NULL)
50 return 1; // erreur lors de la creation du contexte opengl
51
52 // etape 3 : creation des objets
53 if(init() < 0)
54 {
55 printf("[error] init failed.\n");
56 return 1;
57 }
58
59 // etape 4 : affichage de l'application, tant que la fenetre n'est pas fermee. ou que draw() ne renvoie pas 0
60 run(window, draw);
61
62 // etape 5 : nettoyage
63 quit();
64 release_context(context);
65 release_window(window);
66 return 0;
67}
Context create_context(Window window)
cree et configure un contexte opengl
Definition window.cpp:344
void release_window(Window window)
destruction de la fenetre.
Definition window.cpp:314
int run(Window window, int(*draw)())
boucle de gestion des evenements de l'application.
Definition window.cpp:145
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
Definition text.cpp:140
Window create_window(const int w, const int h, const int major, const int minor, const int samples)
creation d'une fenetre pour l'application.
Definition window.cpp:249
void release_context(Context context)
detruit le contexte openGL.
Definition window.cpp:404
int init(std::vector< const char * > &options)