File: modelloader.c

package info (click to toggle)
s3d 0.2.2.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,356 kB
  • sloc: ansic: 21,128; python: 488; perl: 98; makefile: 31; sh: 29
file content (46 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: GPL-2.0-or-later
/* SPDX-FileCopyrightText: 2004-2015  Simon Wunderlich <sw@simonwunderlich.de>
 */




#include <s3d.h>
#include <stdio.h>  /* NULL */
#include <time.h> /* nanosleep() */
#define S3DUNUSED(x) x
static struct timespec t = {
	0, 100*1000*1000
}; /* 100 mili seconds */
static int i, oid;
static void mainloop(void)
{
	s3d_rotate(oid, 0, (float)i, 0);
	i = (i + 1) % 360;
	nanosleep(&t, NULL);
}
static int object_click(struct s3d_evt *S3DUNUSED(evt))
{
	s3d_quit();
	return 0;
}

int main(int argc, char **argv)
{
	if (argc < 2) {
		printf("usage: %s [somefile.3ds]\n", argv[0]);
		return -1;
	}
	if (!s3d_init(&argc, &argv, "modelloader")) {
		s3d_set_callback(S3D_EVENT_OBJ_CLICK, object_click);
		i = 0;
		if (-1 != (oid = s3d_import_model_file(argv[1]))) {
			s3d_flags_on(oid, S3D_OF_VISIBLE | S3D_OF_SELECTABLE);
			s3d_mainloop(mainloop);
		} else {
			printf("file not found ... \n");
		}
		s3d_quit();
	}
	return 0;
}