Skip to content

Commit

Permalink
Merge pull request #22 from ps2dev/ImproveGlutIdleFuncUsage
Browse files Browse the repository at this point in the history
Fix usage of IdleFunc
  • Loading branch information
uyjulian authored Sep 10, 2024
2 parents 235ce1e + edc309b commit 2fb8ebb
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 51 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container: ps2dev/ps2sdk-ports:latest
container: ps2dev/ps2sdk:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install dependencies
run: |
Expand Down Expand Up @@ -43,6 +43,7 @@ jobs:
cd examples
cd box && make clean all && cd ..
cd logo && make clean all && cd ..
cd performance && make clean all && cd ..
cd tricked_out && make clean all && cd ..
cd nehe/lesson02 && make clean all && cd ../..
cd nehe/lesson03 && make clean all && cd ../..
Expand All @@ -51,7 +52,7 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: examples
path: |
Expand Down
30 changes: 11 additions & 19 deletions examples/logo/logo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
#include "GL/gl.h"
#include "GL/glut.h"

// in 'shared_code'
#include "file_ops.h"

#include "ps2glmesh.h"

/********************************************
Expand Down Expand Up @@ -79,12 +76,7 @@ GLint ps2_list, gl_list, wet_list, circle_list, tri_list, square_list, x_list;

int main(int argc, char** argv)
{
int dummy_argc = 1;
char iop_module_path[] = "iop_module_path=host0:/usr/local/sce/iop/modules";
char* dummy_argv[1];
dummy_argv[0] = iop_module_path;

glutInit(&dummy_argc, (char**)dummy_argv);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow(argv[0]);

Expand Down Expand Up @@ -128,8 +120,8 @@ void init_models(void)
// ps2

ps2_list = glGenLists(7);
mesh = LoadMesh(FILE_PREFIX "ps2.gl");
LoadRTexFile(FILE_PREFIX "plywd_b.rtx", tex_ids[0]);
mesh = LoadMesh("ps2.gl");
LoadRTexFile("plywd_b.rtx", tex_ids[0]);
glNewList(ps2_list, GL_COMPILE);
{
glPushMatrix();
Expand All @@ -142,8 +134,8 @@ void init_models(void)
// gl

gl_list = ps2_list + 1;
mesh = LoadMesh(FILE_PREFIX "gl.gl");
LoadRTexFile(FILE_PREFIX "plywd_y.rtx", tex_ids[1]);
mesh = LoadMesh("gl.gl");
LoadRTexFile("plywd_y.rtx", tex_ids[1]);
glNewList(gl_list, GL_COMPILE);
{
glBindTexture(GL_TEXTURE_2D, tex_ids[1]);
Expand All @@ -154,8 +146,8 @@ void init_models(void)
// wet paint

wet_list = ps2_list + 2;
mesh = LoadMesh(FILE_PREFIX "note.gl");
LoadRTexFile(FILE_PREFIX "wetpaint.rtx", tex_ids[2]);
mesh = LoadMesh("note.gl");
LoadRTexFile("wetpaint.rtx", tex_ids[2]);
glNewList(wet_list, GL_COMPILE);
{
glBindTexture(GL_TEXTURE_2D, tex_ids[2]);
Expand All @@ -167,7 +159,7 @@ void init_models(void)
// circle

circle_list = ps2_list + 3;
mesh = LoadMesh(FILE_PREFIX "cir.gl");
mesh = LoadMesh("cir.gl");
glNewList(circle_list, GL_COMPILE);
{
DrawMesh(mesh);
Expand All @@ -177,7 +169,7 @@ void init_models(void)
// square

square_list = ps2_list + 4;
mesh = LoadMesh(FILE_PREFIX "sq.gl");
mesh = LoadMesh("sq.gl");
glNewList(square_list, GL_COMPILE);
{
DrawMesh(mesh);
Expand All @@ -187,7 +179,7 @@ void init_models(void)
// triangle

tri_list = ps2_list + 5;
mesh = LoadMesh(FILE_PREFIX "tri.gl");
mesh = LoadMesh("tri.gl");
glNewList(tri_list, GL_COMPILE);
{
DrawMesh(mesh);
Expand All @@ -197,7 +189,7 @@ void init_models(void)
// x

x_list = ps2_list + 6;
mesh = LoadMesh(FILE_PREFIX "x.gl");
mesh = LoadMesh("x.gl");
glNewList(x_list, GL_COMPILE);
{
DrawMesh(mesh);
Expand Down
5 changes: 4 additions & 1 deletion examples/nehe/lesson04/lesson4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void init(GLvoid) // Create Some Everyday Functions
glEnable(GL_LIGHT0);
}

void idle(void) {
}

void display(void) // Create The Display Function
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Expand Down Expand Up @@ -92,7 +95,7 @@ int main(int argc, char **argv) // Create Main Function For Bri
glutCreateWindow("NeHe's OpenGL Framework"); // Window Title (argv[0] for current directory as title)
glutDisplayFunc(display); // Matching Earlier Functions To Their Counterparts
glutReshapeFunc(reshape);
glutIdleFunc(display);
glutIdleFunc(idle);
glutMainLoop(); // Initialize The Main Loop

return 0;
Expand Down
6 changes: 5 additions & 1 deletion examples/nehe/lesson05/lesson5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ void InitGL(GLvoid) // Create Some Everyday Functions
glEnable(GL_LIGHT0);
}

void idle(void) {

}

void display(void) // Create The Display Function
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Expand Down Expand Up @@ -143,7 +147,7 @@ int main(int argc, char **argv) // Create Main Function For Br
InitGL();
glutDisplayFunc(display); // Matching Earlier Functions To Their Counterparts
glutReshapeFunc(reshape);
glutIdleFunc(display);
glutIdleFunc(idle);
glutMainLoop(); // Initialize The Main Loop

return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/performance/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ EE_BIN = performance.elf
EE_CFLAGS := -I$(PS2SDK)/ports/include -I../shared_code/ $(EE_CFLAGS)
EE_CXXFLAGS := -I$(PS2SDK)/ports/include -I../shared_code/ $(EE_CXXFLAGS)
EE_OBJS = performance.o ../shared_code/text_stuff.o
EE_LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib
EE_LIBS = -lps2glut -lps2gl -lps2stuff -lpad -ldma -lgs -lpacket -lgraph -lgskit -ldmakit
EE_LDFLAGS += -L$(PS2SDK)/ports/lib
EE_LIBS = -lps2glut -lps2gl -lps2stuff -lpad -ldma -lgs -lpacket -lgraph

ifeq ($(DEBUG), 1)
EE_CFLAGS += -D_DEBUG
Expand Down
2 changes: 2 additions & 0 deletions examples/performance/performance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,8 @@ void display(void)
// printf("\n");

display_ticks = timer1->GetTicks();

glutSwapBuffers();
}

void perspective(float fov, float aspect, float nearClip, float farClip)
Expand Down
21 changes: 0 additions & 21 deletions examples/shared_code/file_ops.h

This file was deleted.

3 changes: 1 addition & 2 deletions examples/tricked_out/tricked_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "ps2s/eetimer.h"
#include "ps2s/math.h"

#include "file_ops.h"
#include "text_stuff.h"

#include "billboard_renderer.h"
Expand Down Expand Up @@ -189,7 +188,7 @@ void init_billboards()
void load_bb_texture()
{
// the texture file is just an rgba image with no header info
int tex_fd = open(FILE_PREFIX "car.bin", O_RDONLY);
int tex_fd = open("car.bin", O_RDONLY);
assert(tex_fd != -1);

int image_size = 128 * 128 * 4; // 128x128 32-bit image
Expand Down
4 changes: 2 additions & 2 deletions glut/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
EE_LIB = libps2glut.a

EE_LDFLAGS += -L. -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib
EE_INCS += -I./include -I$(PS2SDK)/ports/include -I$(PS2DEV)/gsKit/include
EE_LDFLAGS += -L. -L$(PS2SDK)/ports/lib
EE_INCS += -I./include -I$(PS2SDK)/ports/include

ifeq ($(DEBUG), 1)
EE_CFLAGS += -D_DEBUG
Expand Down

0 comments on commit 2fb8ebb

Please sign in to comment.