103 lines
2.6 KiB
C
103 lines
2.6 KiB
C
/*
|
|
* JoeyLib 3D
|
|
* Copyright (C) 2019 Scott Duensing <scott@kangaroopunch.com>
|
|
*
|
|
* This software is provided 'as-is', without any express or implied
|
|
* warranty. In no event will the authors be held liable for any damages
|
|
* arising from the use of this software.
|
|
*
|
|
* Permission is granted to anyone to use this software for any purpose,
|
|
* including commercial applications, and to alter it and redistribute it
|
|
* freely, subject to the following restrictions:
|
|
*
|
|
* 1. The origin of this software must not be misrepresented; you must not
|
|
* claim that you wrote the original software. If you use this software
|
|
* in a product, an acknowledgment in the product documentation would be
|
|
* appreciated but is not required.
|
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
* misrepresented as being the original software.
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#define JOEY_MAIN
|
|
#include "joey.h"
|
|
|
|
#ifdef JOEY_IIGS
|
|
segment "j3dTest";
|
|
#endif
|
|
|
|
#include "j3d.h"
|
|
|
|
|
|
void printAt(jlStaT *font, jint16 x, jint16 y, char *string) {
|
|
juint16 i;
|
|
byte c;
|
|
jint16 sx = x;
|
|
jint16 tx;
|
|
jint16 ty;
|
|
|
|
for (i=0; i<strlen(string); i++) {
|
|
c = (byte)string[i];
|
|
tx = c % 40;
|
|
ty = c / 40;
|
|
jlDrawBlit8x8(font, tx, ty, sx++, y);
|
|
}
|
|
}
|
|
|
|
|
|
int main(void) {
|
|
jlStaT *font = NULL;
|
|
j3WorldT *world = NULL;
|
|
bool r;
|
|
|
|
jlUtilStartup("JoeyLib 3D");
|
|
jlStaLoad(font, "font");
|
|
|
|
printAt(font, 1, 1, "Starting JoeyLib3D...");
|
|
jlDisplayPresent();
|
|
j3UtilStartup();
|
|
|
|
printAt(font, 1, 1, "Loading object... ");
|
|
jlDisplayPresent();
|
|
r = j3WorldLoad(world, "cube");
|
|
if (r) {
|
|
printAt(font, 1, 1, "Object loading: Success!");
|
|
jlDisplayPresent();
|
|
} else {
|
|
printAt(font, 1, 1, "Object loading: Failed.");
|
|
jlDisplayPresent();
|
|
}
|
|
|
|
//***TODO*** Add methods to inspect world/object information
|
|
//printf("Verticies: %d\n", sb_count(world->objects[0].verticies));
|
|
//printf("Triangles: %d\n", sb_count(world->objects[0].triangles));
|
|
|
|
j3ObjectMoveTo(world->objects[0], 0, 0, 300); // Matching values in code I'm studying
|
|
j3ObjectScaleTo(world->objects[0], 30, 30, 30); // Matching values in code I'm studying
|
|
|
|
while (!jlKeyPressed() && !jlUtilMustExit()) {
|
|
j3ObjectRotate(world->objects[0], 2, 4, 6); // Matching values in code I'm studying
|
|
j3ObjectUpdate(world->objects[0]);
|
|
|
|
jlDrawColor(0);
|
|
jlDrawClear();
|
|
|
|
jlDrawColor(15);
|
|
jlDrawBox(0, 0, 319, 199);
|
|
j3DrawWireframe(world->objects[0]);
|
|
|
|
jlDisplayPresent();
|
|
}
|
|
jlKeyRead();
|
|
|
|
j3WorldFree(world);
|
|
jlStaFree(font);
|
|
|
|
j3UtilShutdown();
|
|
jlUtilShutdown();
|
|
}
|
|
|