Skip to content

Commit 4af8053

Browse files
committed
Fix some warnings/errors in examples and demos
1 parent 6471dce commit 4af8053

File tree

8 files changed

+27
-23
lines changed

8 files changed

+27
-23
lines changed

demos/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ int main(int argc, char** argv)
453453
glDrawArrays(GL_LINES, 0, line_verts.size());
454454

455455

456-
glBindTexture(GL_TEXTURE_2D, textures[tex_index]);
456+
glBindTexture(GL_TEXTURE_2D, textures[2]);
457457
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, the_Context.back_buffer.buf);
458458

459459
if (!depth_test)
@@ -463,7 +463,7 @@ int main(int argc, char** argv)
463463

464464

465465
glUseProgram(my_programs[cur_shader]);
466-
the_uniforms.tex = textures[tex_index];
466+
the_uniforms.tex = textures[2];
467467

468468
the_uniforms.mvp = MVP;
469469

@@ -669,20 +669,22 @@ bool handle_events()
669669
} else if (keysym.sym == SDLK_1) {
670670
tex_index = (tex_index + 1) % NUM_TEXTURES;
671671
the_uniforms.tex = textures[tex_index];
672+
printf("tex_index = %d\n", tex_index);
672673
}
673674

674675
break; //sdl_keydown
675676

676677
case SDL_WINDOWEVENT:
677678
switch (event.window.event) {
678-
case SDL_WINDOWEVENT_RESIZED:
679+
case SDL_WINDOWEVENT_SIZE_CHANGED:
679680
printf("window size %d x %d\n", event.window.data1, event.window.data2);
680681
width = event.window.data1;
681682
height = event.window.data2;
682683

683684
remake_projection = true;
684685

685-
bbufpix = (u32*)pglResizeFramebuffer(width, height);
686+
pglResizeFramebuffer(width, height);
687+
bbufpix = (u32*)pglGetBackBuffer();
686688
glViewport(0, 0, width, height);
687689
SDL_DestroyTexture(tex);
688690
tex = SDL_CreateTexture(ren, PIX_FORMAT, SDL_TEXTUREACCESS_STREAMING, width, height);

demos/sphereworld.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,14 +817,15 @@ bool handle_events()
817817

818818
case SDL_WINDOWEVENT:
819819
switch (event.window.event) {
820-
case SDL_WINDOWEVENT_RESIZED:
820+
case SDL_WINDOWEVENT_SIZE_CHANGED:
821821
printf("window size %d x %d\n", event.window.data1, event.window.data2);
822822
width = event.window.data1;
823823
height = event.window.data2;
824824

825825
remake_projection = true;
826826

827-
bbufpix = (u32*)pglResizeFramebuffer(width, height);
827+
pglResizeFramebuffer(width, height);
828+
bbufpix = (u32*)pglGetBackBuffer();
828829
glViewport(0, 0, width, height);
829830
SDL_DestroyTexture(tex);
830831
tex = SDL_CreateTexture(ren, PIX_FORMAT, SDL_TEXTUREACCESS_STREAMING, width, height);

demos/sphereworld_color.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,8 @@ int handle_events(GLFrame& camera_frame, unsigned int last_time, unsigned int cu
493493

494494
remake_projection = true;
495495

496-
bbufpix = (u32*)pglResizeFramebuffer(width, height);
496+
pglResizeFramebuffer(width, height);
497+
bbufpix = (u32*)pglGetBackBuffer();
497498
glViewport(0, 0, width, height);
498499
SDL_DestroyTexture(tex);
499500
tex = SDL_CreateTexture(ren, PIX_FORMAT, SDL_TEXTUREACCESS_STREAMING, width, height);

demos/testprimitives.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ typedef struct shader_pair
116116
vert_func vs;
117117
frag_func fs;
118118
int n_interp;
119-
int interp[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
119+
GLenum interp[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
120120
int use_fragdepth_or_discard;
121121
} shader_pair;
122122

examples/ex1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void uniform_color_fs(float* fs_input, Shader_Builtins* builtins, void* uniforms
116116
builtins->gl_FragColor = ((My_Uniforms*)uniforms)->v_color;
117117
}
118118

119-
void setup_context()
119+
void setup_context(void)
120120
{
121121
if (SDL_Init(SDL_INIT_VIDEO)) {
122122
printf("SDL_Init error: %s\n", SDL_GetError());
@@ -140,7 +140,7 @@ void setup_context()
140140
}
141141
}
142142

143-
void cleanup()
143+
void cleanup(void)
144144
{
145145
free_glContext(&the_Context);
146146

@@ -151,7 +151,7 @@ void cleanup()
151151
SDL_Quit();
152152
}
153153

154-
int handle_events()
154+
int handle_events(void)
155155
{
156156
SDL_Event e;
157157
int sc;

examples/ex2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void smooth_fs(float* fs_input, Shader_Builtins* builtins, void* uniforms)
105105
builtins->gl_FragColor = ((vec4*)fs_input)[0];
106106
}
107107

108-
void setup_context()
108+
void setup_context(void)
109109
{
110110
if (SDL_Init(SDL_INIT_VIDEO)) {
111111
printf("SDL_Init error: %s\n", SDL_GetError());
@@ -128,7 +128,7 @@ void setup_context()
128128
}
129129
}
130130

131-
void cleanup()
131+
void cleanup(void)
132132
{
133133
free_glContext(&the_Context);
134134

@@ -139,7 +139,7 @@ void cleanup()
139139
SDL_Quit();
140140
}
141141

142-
int handle_events()
142+
int handle_events(void)
143143
{
144144
SDL_Event e;
145145
int sc;

examples/ex3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void smooth_fs(float* fs_input, Shader_Builtins* builtins, void* uniforms)
131131
builtins->gl_FragColor = ((vec4*)fs_input)[0];
132132
}
133133

134-
void setup_context()
134+
void setup_context(void)
135135
{
136136
if (SDL_Init(SDL_INIT_VIDEO)) {
137137
printf("SDL_Init error: %s\n", SDL_GetError());
@@ -154,7 +154,7 @@ void setup_context()
154154
}
155155
}
156156

157-
void cleanup()
157+
void cleanup(void)
158158
{
159159
free_glContext(&the_Context);
160160

@@ -165,7 +165,7 @@ void cleanup()
165165
SDL_Quit();
166166
}
167167

168-
int handle_events()
168+
int handle_events(void)
169169
{
170170
SDL_Event e;
171171
int sc;

examples/lines.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ int blending;
4141
int smooth;
4242
float granularity;
4343

44-
void cleanup();
45-
void setup_context();
46-
int handle_events();
44+
void cleanup(void);
45+
void setup_context(void);
46+
int handle_events(void);
4747

4848
typedef struct vert_data
4949
{
@@ -181,7 +181,7 @@ int main(int argc, char** argv)
181181
return 0;
182182
}
183183

184-
void setup_context()
184+
void setup_context(void)
185185
{
186186
if (SDL_Init(SDL_INIT_VIDEO)) {
187187
printf("SDL_Init error: %s\n", SDL_GetError());
@@ -206,7 +206,7 @@ void setup_context()
206206
}
207207
}
208208

209-
void cleanup()
209+
void cleanup(void)
210210
{
211211

212212
free_glContext(&the_Context);
@@ -218,7 +218,7 @@ void cleanup()
218218
SDL_Quit();
219219
}
220220

221-
int handle_events()
221+
int handle_events(void)
222222
{
223223
SDL_Event e;
224224
int sc;

0 commit comments

Comments
 (0)