Skip to content

Commit

Permalink
parser progress with tri added
Browse files Browse the repository at this point in the history
  • Loading branch information
PixelatedLagg committed Nov 15, 2023
1 parent 4463a99 commit 58eb4fa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
Binary file modified p3d.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion src/display.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DISPLAY_H
#define DISPLAY_H

#include "quad.h"
#include "prim.h"

extern quad* quads;

Expand Down
3 changes: 0 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <GL/glu.h>
#include <stdio.h>

#include "main.h"
#include "display.h"
#include "parse.h"

Expand Down Expand Up @@ -58,8 +57,6 @@ void passiveMotion(int x, int y)

int main(int argc, char* argv[])
{
parse("levels/map.lvl");
return 0;
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);

Expand Down
Empty file removed src/main.h
Empty file.
18 changes: 14 additions & 4 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ void parse(char* file)

char readBuffer[100];

char currentChar;
while (fgets(readBuffer, sizeof(readBuffer), data) != NULL)
{
if (!isdigit(readBuffer[0]))
{
char *buff = (char*)malloc(10 * sizeof(char));
memcpy(buff, &readBuffer[2], strlen(readBuffer) - 2);
quads = (quad*)malloc(atoi(buff) * sizeof(quad)); //assign quad# from float in buff
free(buff);
char *count = (char*)malloc(10 * sizeof(char));
memcpy(count, &readBuffer[2], strlen(readBuffer) - 2);
switch (readBuffer[0])
{
case 'q':
quads = (quad*)malloc(atoi(count) * sizeof(quad)); //assign quad# from float in count
break;
case 't':

break;
}
free(count);
continue;
}
int i = 0;
while (readBuffer[i] != '\n')
Expand Down
9 changes: 7 additions & 2 deletions src/quad.h → src/prim.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef QUAD_H
#define QUAD_H
#ifndef PRIM_H
#define PRIM_H

#include <GL/gl.h>

Expand All @@ -8,4 +8,9 @@ typedef struct
GLfloat v1_x, v1_y, v1_z, v2_x, v2_y, v2_z, v3_x, v3_y, v3_z, v4_x, v4_y, v4_z;
} quad;

typedef struct
{
GLfloat v1_x, v1_y, v1_z, v2_x, v2_y, v2_z, v3_x, v3_y, v3_z;
} tri;

#endif

0 comments on commit 58eb4fa

Please sign in to comment.