3 #include <SDL/SDL_opengl.h>
13 #define RGB(R,G,B) ((rgba_t) {.colors.r = R, .colors.g = G, .colors.b = B, .colors.a = 0xff})
20 static rgba_t pic
[PIC_H
][PIC_W
];
25 #define COL1 RGB(0x0, 0xff, 0)
26 #define COL2 RGB(0xff, 0xff, 0xff)
27 for(y
=0; y
<PIC_H
; y
++) for(x
=0;x
<PIC_W
;x
++)
28 if(y
== 4 || x
== 4) pic
[y
][x
] = COL2
;
29 else pic
[y
][x
] = COL1
;
32 glBindTexture(GL_TEXTURE_2D
, texid
);
35 glTexCoord2f(0,0); glVertex2i(-1,-1);
36 glTexCoord2f(1,0); glVertex2i( 1,-1);
37 glTexCoord2f(1,1); glVertex2i( 1, 1);
38 glTexCoord2f(0,1); glVertex2i(-1, 1);
40 glTexCoord2f(0,0); glVertex2i(-1,1);
41 glTexCoord2f(1,0); glVertex2i(1,1);
42 glTexCoord2f(1,1); glVertex2i(1,-1);
43 glTexCoord2f(0,1); glVertex2i(-1, -1);
49 void video_init(void) {
51 SDL_Init(SDL_INIT_VIDEO
);
52 SDL_Surface
*surface
= SDL_SetVideoMode(VMODE_W
, VMODE_H
, 32, SDL_OPENGL
);
53 glViewport(0, 0, PIC_W
, PIC_H
);
54 glMatrixMode(GL_PROJECTION
); // Select The Projection Matrix
55 glLoadIdentity(); // Reset The Projection Matrix
56 glEnable(GL_TEXTURE_2D
);
57 glGenTextures(1, &texid
);
58 glBindTexture(GL_TEXTURE_2D
, texid
);
60 glTexImage2D(GL_TEXTURE_2D
, 0, mode
, PIC_W
, PIC_H
, 0, mode
, GL_UNSIGNED_BYTE
, pic
);
61 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
62 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
63 dprintf(2, "%s\n", glGetString(GL_RENDERER
));
70 while (SDL_PollEvent(&sdl_event
)) {
71 switch (sdl_event
.type
) {