static void testcase1(const char *desc) { ggi_visual_t vis; ggi_color green, back; int err; printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc); if (dontrun) return; err = ggiInit(); printassert(err == GGI_OK, "ggiInit failed with %i\n", err); vis = ggiOpen(NULL); printassert(vis != NULL, "ggiOpen() failed\n"); err = ggiSetGraphMode(vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_8BIT); if(err < 0) { printassert(0, "Palettized mode not available.\n"); printsuccess(); ggiClose(vis); ggiExit(); return; } green.r = 100; green.g = 40000; green.b = 4000; err = ggiSetPalette(vis, GGI_PALETTE_DONTCARE, 1, &green); if (err < 0) { printfailure("Unable to install colormap with one entry.\n"); ggiClose(vis); ggiExit(); return; } printassert(err == (int)ggiMapColor(vis, &green), "ggiMapColor inconsistent with retval of ggiSetPalette.\n"); ggiUnmapPixel(vis, err, &back); if(green.r != back.r || green.g != back.g || green.b != back.b) { printfailure("Unexpected color from ggiUnmapPixel.\n"); ggiClose(vis); ggiExit(); return; } ggiSetGCForeground(vis, err); ggiDrawBox(vis, 0, 0, 3000, 3000); ggiFlush(vis); /* You should see a green square, how to test this? */ ggUSleep(5000000); printsuccess(); ggiClose(vis); ggiExit(); }
int gr_set_mode(u_int32_t mode) { unsigned int w, h; ggi_mode other_mode; #ifdef NOGRAPH return 0; #endif if (mode<=0) return 0; w=SM_W(mode); h=SM_H(mode); gr_palette_clear(); if(ggiCheckGraphMode(screenvis, w, h, GGI_AUTO, GGI_AUTO, GT_8BIT, &other_mode)) ggiSetMode(screenvis, &other_mode); else ggiSetGraphMode(screenvis, w, h, GGI_AUTO, GGI_AUTO, GT_8BIT); ggiSetFlags(screenvis, GGIFLAG_ASYNC); if (!ggiDBGetNumBuffers(screenvis)) use_directbuffer = 0; else { dbuffer = ggiDBGetBuffer(screenvis, 0); if (!(dbuffer->type & GGI_DB_SIMPLE_PLB)) use_directbuffer = 0; else use_directbuffer = 1; } memset(grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_mode = mode; grd_curscreen->sc_w = w; grd_curscreen->sc_h = h; grd_curscreen->sc_aspect = fixdiv(grd_curscreen->sc_w*3,grd_curscreen->sc_h*4); grd_curscreen->sc_canvas.cv_bitmap.bm_x = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_y = 0; grd_curscreen->sc_canvas.cv_bitmap.bm_w = w; grd_curscreen->sc_canvas.cv_bitmap.bm_h = h; grd_curscreen->sc_canvas.cv_bitmap.bm_type = BM_LINEAR; if (use_directbuffer) { grd_curscreen->sc_canvas.cv_bitmap.bm_data = dbuffer->write; grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = dbuffer->buffer.plb.stride; } else { free(screenbuffer); screenbuffer = malloc (w * h); grd_curscreen->sc_canvas.cv_bitmap.bm_data = screenbuffer; grd_curscreen->sc_canvas.cv_bitmap.bm_rowsize = w; } gr_set_current_canvas(NULL); gamefont_choose_game_font(w,h); return 0; }
void Init() { GLfloat h=(GLfloat)3/4; GLfloat pos[4]={5,5,-20,0}; GLfloat specular[4]={.4,.4,.4,1}; GLfloat diffuse[4]={.3,.3,.3,1}; GLfloat ambient[4]={.2,.2,.2,1}; int err; if (ggiInit()<0) { printf("ggiInit() failed\n"); exit(1); } ctx=GGIMesaCreateContext(); if (ctx==NULL) { printf("Can't create Context!\n"); exit(1); } vis=ggiOpen(NULL); vis_mem=ggiOpen("display-memory",NULL); if (vis==NULL || vis_mem==NULL) { printf("Can't open ggi_visuals!\n"); exit(1); } err=ggiSetGraphMode(vis,screen_x,screen_y,screen_x,screen_y,bpp); err+=ggiSetGraphMode(vis_mem,screen_x,screen_y,screen_x,screen_y,bpp); if (err) { printf("Can't set %ix%i\n",screen_x,screen_y); exit(1); } if (GGIMesaSetVisual(ctx,vis_mem,GL_TRUE,GL_FALSE)<0) { printf("GGIMesaSetVisual() failed!\n"); exit(1); } GGIMesaMakeCurrent(ctx); glViewport(0,0,screen_x,screen_y); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1,1,-h,h,1,50); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0,0,-9); glShadeModel(GL_FLAT); glFrontFace(GL_CW); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0,GL_POSITION,pos); glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuse); glLightfv(GL_LIGHT0,GL_AMBIENT,ambient); glLightfv(GL_LIGHT0,GL_SPECULAR,specular); #ifdef ZBUFFER glEnable(GL_DEPTH_TEST); #endif }