Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Window-creation/C/window-creation-1.c
Normal file
22
Task/Window-creation/C/window-creation-1.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Opens an 800x600 16bit color window.
|
||||
* Done here with ANSI C.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "SDL.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
SDL_Surface *screen;
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
atexit(SDL_Quit);
|
||||
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
|
||||
|
||||
return 0;
|
||||
}
|
||||
16
Task/Window-creation/C/window-creation-2.c
Normal file
16
Task/Window-creation/C/window-creation-2.c
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_signal_connect(GTK_OBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
|
||||
gtk_widget_show(window);
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
15
Task/Window-creation/C/window-creation-3.c
Normal file
15
Task/Window-creation/C/window-creation-3.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
||||
gtk_widget_show(window);
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
40
Task/Window-creation/C/window-creation-4.c
Normal file
40
Task/Window-creation/C/window-creation-4.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// A C+GLUT implementation of the Creating a Window task at Rosetta Code
|
||||
// http://rosettacode.org/wiki/Creating_a_Window
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
// This function is not strictly necessary to meet the requirements of the task.
|
||||
void onKeyPress(unsigned char key, int x, int y)
|
||||
{
|
||||
// If you have any cleanup or such, you need to use C's
|
||||
// onexit routine for registering cleanup callbacks.
|
||||
exit(0);
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Pulls out any command-line arguments that are specific to GLUT,
|
||||
// And leaves a command-line argument set without any of those arguments
|
||||
// when it returns.
|
||||
// (If you want a copy, take a copy first.)
|
||||
glutInit(&argc, argv);
|
||||
|
||||
// Tell GLUT we want to create a window.
|
||||
// It won't *actually* be created until we call glutMainLoop below.
|
||||
glutCreateWindow("Goodbye, World!");
|
||||
|
||||
// Register a callback to handle key press events (so we can quit on
|
||||
// when someone hits a key) This part is not necessary to meet the
|
||||
// requirements of the task.
|
||||
glutKeyboardFunc(&onKeyPress);
|
||||
|
||||
// Put the execution of the app in glut's hands. Most GUI environments
|
||||
// involve a message loop that communicate window events. GLUT handles
|
||||
// most of these with defaults, except for any we register callbacks
|
||||
// for. (Like the onKeyPress above.)
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue