Skip to content

Commit 2fb8ebb

Browse files
authored
Merge pull request #22 from ps2dev/ImproveGlutIdleFuncUsage
Fix usage of IdleFunc
2 parents 235ce1e + edc309b commit 2fb8ebb

File tree

9 files changed

+31
-51
lines changed

9 files changed

+31
-51
lines changed

.github/workflows/compilation.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ on:
99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
12-
container: ps2dev/ps2sdk-ports:latest
12+
container: ps2dev/ps2sdk:latest
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515

1616
- name: Install dependencies
1717
run: |
@@ -43,6 +43,7 @@ jobs:
4343
cd examples
4444
cd box && make clean all && cd ..
4545
cd logo && make clean all && cd ..
46+
cd performance && make clean all && cd ..
4647
cd tricked_out && make clean all && cd ..
4748
cd nehe/lesson02 && make clean all && cd ../..
4849
cd nehe/lesson03 && make clean all && cd ../..
@@ -51,7 +52,7 @@ jobs:
5152
5253
5354
- name: Upload artifacts
54-
uses: actions/upload-artifact@v3
55+
uses: actions/upload-artifact@v4
5556
with:
5657
name: examples
5758
path: |

examples/logo/logo.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
#include "GL/gl.h"
1515
#include "GL/glut.h"
1616

17-
// in 'shared_code'
18-
#include "file_ops.h"
19-
2017
#include "ps2glmesh.h"
2118

2219
/********************************************
@@ -79,12 +76,7 @@ GLint ps2_list, gl_list, wet_list, circle_list, tri_list, square_list, x_list;
7976

8077
int main(int argc, char** argv)
8178
{
82-
int dummy_argc = 1;
83-
char iop_module_path[] = "iop_module_path=host0:/usr/local/sce/iop/modules";
84-
char* dummy_argv[1];
85-
dummy_argv[0] = iop_module_path;
86-
87-
glutInit(&dummy_argc, (char**)dummy_argv);
79+
glutInit(&argc, argv);
8880
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
8981
glutCreateWindow(argv[0]);
9082

@@ -128,8 +120,8 @@ void init_models(void)
128120
// ps2
129121

130122
ps2_list = glGenLists(7);
131-
mesh = LoadMesh(FILE_PREFIX "ps2.gl");
132-
LoadRTexFile(FILE_PREFIX "plywd_b.rtx", tex_ids[0]);
123+
mesh = LoadMesh("ps2.gl");
124+
LoadRTexFile("plywd_b.rtx", tex_ids[0]);
133125
glNewList(ps2_list, GL_COMPILE);
134126
{
135127
glPushMatrix();
@@ -142,8 +134,8 @@ void init_models(void)
142134
// gl
143135

144136
gl_list = ps2_list + 1;
145-
mesh = LoadMesh(FILE_PREFIX "gl.gl");
146-
LoadRTexFile(FILE_PREFIX "plywd_y.rtx", tex_ids[1]);
137+
mesh = LoadMesh("gl.gl");
138+
LoadRTexFile("plywd_y.rtx", tex_ids[1]);
147139
glNewList(gl_list, GL_COMPILE);
148140
{
149141
glBindTexture(GL_TEXTURE_2D, tex_ids[1]);
@@ -154,8 +146,8 @@ void init_models(void)
154146
// wet paint
155147

156148
wet_list = ps2_list + 2;
157-
mesh = LoadMesh(FILE_PREFIX "note.gl");
158-
LoadRTexFile(FILE_PREFIX "wetpaint.rtx", tex_ids[2]);
149+
mesh = LoadMesh("note.gl");
150+
LoadRTexFile("wetpaint.rtx", tex_ids[2]);
159151
glNewList(wet_list, GL_COMPILE);
160152
{
161153
glBindTexture(GL_TEXTURE_2D, tex_ids[2]);
@@ -167,7 +159,7 @@ void init_models(void)
167159
// circle
168160

169161
circle_list = ps2_list + 3;
170-
mesh = LoadMesh(FILE_PREFIX "cir.gl");
162+
mesh = LoadMesh("cir.gl");
171163
glNewList(circle_list, GL_COMPILE);
172164
{
173165
DrawMesh(mesh);
@@ -177,7 +169,7 @@ void init_models(void)
177169
// square
178170

179171
square_list = ps2_list + 4;
180-
mesh = LoadMesh(FILE_PREFIX "sq.gl");
172+
mesh = LoadMesh("sq.gl");
181173
glNewList(square_list, GL_COMPILE);
182174
{
183175
DrawMesh(mesh);
@@ -187,7 +179,7 @@ void init_models(void)
187179
// triangle
188180

189181
tri_list = ps2_list + 5;
190-
mesh = LoadMesh(FILE_PREFIX "tri.gl");
182+
mesh = LoadMesh("tri.gl");
191183
glNewList(tri_list, GL_COMPILE);
192184
{
193185
DrawMesh(mesh);
@@ -197,7 +189,7 @@ void init_models(void)
197189
// x
198190

199191
x_list = ps2_list + 6;
200-
mesh = LoadMesh(FILE_PREFIX "x.gl");
192+
mesh = LoadMesh("x.gl");
201193
glNewList(x_list, GL_COMPILE);
202194
{
203195
DrawMesh(mesh);

examples/nehe/lesson04/lesson4.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ void init(GLvoid) // Create Some Everyday Functions
3535
glEnable(GL_LIGHT0);
3636
}
3737

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

98101
return 0;

examples/nehe/lesson05/lesson5.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ void InitGL(GLvoid) // Create Some Everyday Functions
3535
glEnable(GL_LIGHT0);
3636
}
3737

38+
void idle(void) {
39+
40+
}
41+
3842
void display(void) // Create The Display Function
3943
{
4044
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
@@ -143,7 +147,7 @@ int main(int argc, char **argv) // Create Main Function For Br
143147
InitGL();
144148
glutDisplayFunc(display); // Matching Earlier Functions To Their Counterparts
145149
glutReshapeFunc(reshape);
146-
glutIdleFunc(display);
150+
glutIdleFunc(idle);
147151
glutMainLoop(); // Initialize The Main Loop
148152

149153
return 0;

examples/performance/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ EE_BIN = performance.elf
22
EE_CFLAGS := -I$(PS2SDK)/ports/include -I../shared_code/ $(EE_CFLAGS)
33
EE_CXXFLAGS := -I$(PS2SDK)/ports/include -I../shared_code/ $(EE_CXXFLAGS)
44
EE_OBJS = performance.o ../shared_code/text_stuff.o
5-
EE_LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib
6-
EE_LIBS = -lps2glut -lps2gl -lps2stuff -lpad -ldma -lgs -lpacket -lgraph -lgskit -ldmakit
5+
EE_LDFLAGS += -L$(PS2SDK)/ports/lib
6+
EE_LIBS = -lps2glut -lps2gl -lps2stuff -lpad -ldma -lgs -lpacket -lgraph
77

88
ifeq ($(DEBUG), 1)
99
EE_CFLAGS += -D_DEBUG

examples/performance/performance.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ void display(void)
571571
// printf("\n");
572572

573573
display_ticks = timer1->GetTicks();
574+
575+
glutSwapBuffers();
574576
}
575577

576578
void perspective(float fov, float aspect, float nearClip, float farClip)

examples/shared_code/file_ops.h

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/tricked_out/tricked_out.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "ps2s/eetimer.h"
1919
#include "ps2s/math.h"
2020

21-
#include "file_ops.h"
2221
#include "text_stuff.h"
2322

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

195194
int image_size = 128 * 128 * 4; // 128x128 32-bit image

glut/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
EE_LIB = libps2glut.a
22

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

66
ifeq ($(DEBUG), 1)
77
EE_CFLAGS += -D_DEBUG

0 commit comments

Comments
 (0)