annotate test/testshape.c @ 4805:de3b3455f8ec

Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
author Eli Gottlieb <eligottlieb@gmail.com>
date Mon, 19 Jul 2010 00:24:02 -0400
parents b33752266d8f
children 2ae79ed78a5a
rev   line source
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
1 #include <stdlib.h>
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
2 #include <math.h>
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
3 #include <SDL_events.h>
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
4 #include <SDL_rect.h>
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
5 #include <SDL_pixels.h>
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
6 #include <SDL_video.h>
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
7 #include <SDL_shape.h>
4803
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
8 #include <SDL_keysym.h>
4805
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
9 #include <SDL_timer.h>
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
10
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
11 #define SHAPED_WINDOW_X 150
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
12 #define SHAPED_WINDOW_Y 150
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
13 #define SHAPED_WINDOW_DIMENSION 640
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
14
4805
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
15 #define TICK_INTERVAL 18
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
16
4804
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
17 void render(SDL_Window* window,SDL_Texture *texture,SDL_Rect texture_dimensions) {
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
18 SDL_SelectRenderer(window);
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
19
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
20 //Clear render-target to blue.
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
21 SDL_SetRenderDrawColor(0x00,0x00,0xff,0xff);
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
22 SDL_RenderClear();
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
23
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
24 //Render the texture.
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
25 SDL_RenderCopy(texture,&texture_dimensions,&texture_dimensions);
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
26
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
27 SDL_RenderPresent();
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
28 }
b33752266d8f Boxed up the rendering loop and turned it into a redraw/update function. This makes things way more responsive, usable again.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4803
diff changeset
29
4805
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
30 static Uint32 next_time;
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
31
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
32 Uint32 time_left() {
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
33 Uint32 now = SDL_GetTicks();
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
34 if(next_time <= now)
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
35 return 0;
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
36 else
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
37 return next_time - now;
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
38 }
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
39
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
40 int main(int argc,char** argv) {
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
41 if(argc < 2) {
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
42 printf("SDL_Shape requires at least one bitmap file as argument.\n");
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
43 exit(-1);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
44 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
45
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
46 if(SDL_VideoInit(NULL,0) == -1) {
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
47 printf("Could not initialize SDL video.\n");
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
48 exit(-2);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
49 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
50
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
51 Uint8 num_pictures = argc - 1;
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
52 SDL_Surface **pictures = malloc(sizeof(SDL_Surface*)*num_pictures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
53 int i = 0;
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
54 for(i=0;i<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
55 pictures[i] = NULL;
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
56 for(i=0;i<num_pictures;i++) {
4802
f14a8c05f5bb Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4800
diff changeset
57 pictures[i] = SDL_LoadBMP(argv[i+1]);
f14a8c05f5bb Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4800
diff changeset
58 if(pictures[i] == NULL) {
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
59 int j = 0;
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
60 for(j=0;j<num_pictures;j++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
61 if(pictures[j] != NULL)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
62 SDL_FreeSurface(pictures[j]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
63 free(pictures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
64 SDL_VideoQuit();
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
65 printf("Could not load surface from named bitmap file.\n");
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
66 exit(-3);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
67 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
68 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
69
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
70 SDL_Window *window = SDL_CreateShapedWindow("SDL_Shape test",SHAPED_WINDOW_X,SHAPED_WINDOW_Y,SHAPED_WINDOW_DIMENSION,SHAPED_WINDOW_DIMENSION,SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
71 if(window == NULL) {
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
72 for(i=0;i<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
73 SDL_FreeSurface(pictures[i]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
74 free(pictures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
75 SDL_VideoQuit();
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
76 printf("Could not create shaped window for SDL_Shape.\n");
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
77 exit(-4);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
78 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
79 if(SDL_CreateRenderer(window,-1,SDL_RENDERER_PRESENTFLIP2) == -1) {
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
80 SDL_DestroyWindow(window);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
81 for(i=0;i<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
82 SDL_FreeSurface(pictures[i]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
83 free(pictures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
84 SDL_VideoQuit();
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
85 printf("Could not create rendering context for SDL_Shape window.\n");
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
86 exit(-5);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
87 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
88
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
89 SDL_Texture **textures = malloc(sizeof(SDL_Texture*)*num_pictures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
90 for(i=0;i<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
91 textures[i] = NULL;
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
92 for(i=0;i<num_pictures;i++) {
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
93 textures[i] = SDL_CreateTextureFromSurface(0,pictures[i]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
94 if(textures[i] == NULL) {
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
95 int j = 0;
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
96 for(j=0;j<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
97 if(textures[i] != NULL)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
98 SDL_DestroyTexture(textures[i]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
99 free(textures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
100 for(i=0;i<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
101 SDL_FreeSurface(pictures[i]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
102 free(pictures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
103 SDL_DestroyRenderer(window);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
104 SDL_DestroyWindow(window);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
105 SDL_VideoQuit();
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
106 printf("Could not create texture for SDL_shape.\n");
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
107 exit(-6);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
108 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
109 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
110
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
111 SDL_Event event;
4800
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
112 int event_pending = 0,should_exit = 0;
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
113 event_pending = SDL_PollEvent(&event);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
114 unsigned int current_picture = 0;
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
115 SDL_WindowShapeMode mode = {ShapeModeDefault,1};
4803
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
116 int button_down = 0;
4802
f14a8c05f5bb Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4800
diff changeset
117 Uint32 format = 0,access = 0;
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
118 SDL_Rect texture_dimensions = {0,0,0,0};
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
119 SDL_QueryTexture(textures[current_picture],&format,&access,&texture_dimensions.w,&texture_dimensions.h);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
120 SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
4802
f14a8c05f5bb Minor bugfixes. testshape now draws a shaped window with bizarre, pixellated gashes of transparency across it, and in doing so seems to hog a system resource and slow the rest of the video system down.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4800
diff changeset
121 SDL_SetWindowShape(window,pictures[current_picture],&mode);
4805
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
122 next_time = SDL_GetTicks() + TICK_INTERVAL;
4800
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
123 while(should_exit == 0) {
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
124 event_pending = SDL_PollEvent(&event);
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
125 if(event_pending == 1) {
4803
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
126 if(event.type == SDL_KEYDOWN) {
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
127 button_down = 1;
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
128 if(event.key.keysym.sym == SDLK_ESCAPE)
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
129 should_exit = 1;
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
130 }
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
131 if(button_down && event.type == SDL_KEYUP) {
a4c1df880690 Added code to make testshape switch shapes on keystrokes and exit on an ESC keystroke.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4802
diff changeset
132 button_down = 0;
4800
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
133 current_picture += 1;
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
134 if(current_picture >= num_pictures)
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
135 current_picture = 0;
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
136 SDL_QueryTexture(textures[current_picture],&format,&access,&texture_dimensions.w,&texture_dimensions.h);
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
137 SDL_SetWindowSize(window,texture_dimensions.w,texture_dimensions.h);
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
138 SDL_SetWindowShape(window,pictures[current_picture],&mode);
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
139 }
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
140 if(event.type == SDL_QUIT)
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
141 should_exit = 1;
6d4be626225f Same place as before, but optimizing a bit to try to isolate the spot in the program that locks things up.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4799
diff changeset
142 event_pending = 0;
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
143 }
4805
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
144 render(window,textures[current_picture],texture_dimensions);
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
145 SDL_Delay(time_left());
de3b3455f8ec Put the render loop back in its right place, but with delaying functionality to keep it down to roughly 60fps, not eating up all the X11 time.
Eli Gottlieb <eligottlieb@gmail.com>
parents: 4804
diff changeset
146 next_time += TICK_INTERVAL;
4799
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
147 }
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
148
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
149 //Free the textures.
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
150 for(i=0;i<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
151 SDL_DestroyTexture(textures[i]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
152 free(textures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
153 //Destroy the window.
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
154 SDL_DestroyWindow(window);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
155 //Free the original surfaces backing the textures.
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
156 for(i=0;i<num_pictures;i++)
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
157 SDL_FreeSurface(pictures[i]);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
158 free(pictures);
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
159 //Call SDL_VideoQuit() before quitting.
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
160 SDL_VideoQuit();
a0e096916474 Rewrote test program for shaped windows. It definitely displays recognizable pictures now, but the resizing and shaping functionality isn't behaving correctly, possibly due to a miscalculation of alpha values.
Eli Gottlieb <eligottlieb@gmail.com>
parents:
diff changeset
161 }