Skip to content

Commit

Permalink
Set an icon.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Nov 24, 2015
1 parent b991e01 commit 3addd07
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/con_sdl.cpp
Expand Up @@ -232,7 +232,7 @@ static int SetupSDLWindow(int argc, char **argv) {
const int winw = ScreenCols * FontCX;
const int winh = ScreenRows * FontCY;

win = SDL_CreateWindow(winTitle, initX, initY, winw, winh, SDL_WINDOW_RESIZABLE
win = SDL_CreateWindow(winTitle, initX, initY, winw, winh, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN
#if !USE_SDL2_RENDER_API
| SDL_WINDOW_OPENGL
#endif
Expand All @@ -248,6 +248,27 @@ static int SetupSDLWindow(int argc, char **argv) {
DieError(1, "XFTE Fatal: %s", buf);
}

#ifndef __APPLE__ // mac os x gets its icon elsewhere.
{
const char *envr = SDL_getenv("HOME");
if (envr)
{
const char *fname = ".fte.bmp";
const size_t len = SDL_strlen(envr) + SDL_strlen(fname) + 2;
char *path = new char[len];
SDL_snprintf(path, len, "%s/%s", envr, fname);
SDL_Surface *icon = SDL_LoadBMP(path);
delete[] path;
if (icon)
{
SDL_SetColorKey(icon, 1, SDL_MapRGB(icon->format, 255, 255, 255));
SDL_SetWindowIcon(win, icon);
SDL_FreeSurface(icon);
}
}
}
#endif

SDL_SetWindowMinimumSize(win, MIN_SCRWIDTH * FontCX, MIN_SCRHEIGHT * FontCY);

#if USE_SDL2_RENDER_API
Expand All @@ -265,6 +286,7 @@ static int SetupSDLWindow(int argc, char **argv) {
}

SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);
SDL_ShowWindow(win);
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);

Expand Down Expand Up @@ -317,6 +339,7 @@ static int SetupSDLWindow(int argc, char **argv) {
SDL_GL_SetSwapInterval(0);

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
SDL_ShowWindow(win);
glClear(GL_COLOR_BUFFER_BIT);
SDL_GL_SwapWindow(win);

Expand Down Expand Up @@ -1214,7 +1237,6 @@ int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete) {
SDL_RenderPresent(renderer);
SDL_SetRenderTarget(renderer, backbuffer);
#else
glClear(GL_COLOR_BUFFER_BIT);
unsigned char *dynamic_buffer = new unsigned char[ScreenCols * ScreenRows * 7 * 4];
unsigned char *ptr = dynamic_buffer;
for (int i = 0; i < ScreenCols * ScreenRows * 2; i += 2)
Expand Down Expand Up @@ -1257,6 +1279,8 @@ int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete) {

glBufferSubData(GL_ARRAY_BUFFER, 0, ScreenCols * ScreenRows * 7 * 4, dynamic_buffer);
delete[] dynamic_buffer;

glClear(GL_COLOR_BUFFER_BIT);
glDrawArrays(GL_QUADS, 0, (ScreenCols * ScreenRows) * 4);
SDL_GL_SwapWindow(win);
#endif
Expand Down

0 comments on commit 3addd07

Please sign in to comment.