Bool rfbSetTranslateFunction(rfbClientPtr cl) { rfbLog("Pixel format for client %s:\n",cl->host); PrintPixelFormat(&cl->format); //cl->format = rfbServerFormat; cl->translateFn = rfbTranslateNone; cl->translateLookupTable = NULL; return rfbSetTranslateFunctionUsingFormat(cl, rfbServerFormat); }
Bool SendSetPixelFormat() { rfbSetPixelFormatMsg spf; spf.type = rfbSetPixelFormat; spf.format = myFormat; spf.format.redMax = Swap16IfLE(spf.format.redMax); spf.format.greenMax = Swap16IfLE(spf.format.greenMax); spf.format.blueMax = Swap16IfLE(spf.format.blueMax); PrintPixelFormat(&myFormat); return WriteToRFBServer((char *)&spf, sz_rfbSetPixelFormatMsg); }
rfbBool LibVncImage::resizeImage(rfbClient* client) { LibVncImage* image = (LibVncImage*)(rfbClientGetClientData(client, 0)); int width = client->width; int height = client->height; int depth = client->format.bitsPerPixel; OSG_NOTICE<<"resize "<<width<<", "<<height<<", "<<depth<<" image = "<<image<<std::endl; PrintPixelFormat(&(client->format)); bool swap = client->format.redShift!=0; if (!image->_optionString.empty()) { if (image->_optionString.find("swap")!=std::string::npos || image->_optionString.find("swop")!=std::string::npos) swap = true; } GLenum gl_pixelFormat = swap ? GL_BGRA : GL_RGBA; if (!image->_optionString.empty()) { if (image->_optionString.find("RGB")!=std::string::npos) gl_pixelFormat = GL_RGBA; if (image->_optionString.find("RGBA")!=std::string::npos) gl_pixelFormat = GL_RGBA; if (image->_optionString.find("BGR")!=std::string::npos) gl_pixelFormat = GL_BGRA; if (image->_optionString.find("BGRA")!=std::string::npos) gl_pixelFormat = GL_BGRA; } image->allocateImage(width, height, 1, gl_pixelFormat, GL_UNSIGNED_BYTE); image->setInternalTextureFormat(GL_RGBA); client->frameBuffer= (uint8_t*)(image->data()); return TRUE; }
static void PrintRenderer(SDL_RendererInfo * info) { int i, count; fprintf(stderr, " Renderer %s:\n", info->name); fprintf(stderr, " Flags: 0x%8.8X", info->flags); fprintf(stderr, " ("); count = 0; for (i = 0; i < sizeof(info->flags) * 8; ++i) { Uint32 flag = (1 << i); if (info->flags & flag) { if (count > 0) { fprintf(stderr, " | "); } PrintRendererFlag(flag); ++count; } } fprintf(stderr, ")\n"); fprintf(stderr, " Texture formats (%d): ", info->num_texture_formats); for (i = 0; i < (int) info->num_texture_formats; ++i) { if (i > 0) { fprintf(stderr, ", "); } PrintPixelFormat(info->texture_formats[i]); } fprintf(stderr, "\n"); if (info->max_texture_width || info->max_texture_height) { fprintf(stderr, " Max Texture Size: %dx%d\n", info->max_texture_width, info->max_texture_height); } }
Bool InitialiseRFBConnection(void) { rfbProtocolVersionMsg pv; int server_major, server_minor; int viewer_major, viewer_minor; rfbClientInitMsg ci; int secType; /* if the connection is immediately closed, don't report anything, so that pmw's monitor can make test connections */ if (listenSpecified) errorMessageOnReadFailure = False; if (!ReadFromRFBServer(pv, sz_rfbProtocolVersionMsg)) return False; errorMessageOnReadFailure = True; pv[sz_rfbProtocolVersionMsg] = 0; if (sscanf(pv, rfbProtocolVersionFormat, &server_major, &server_minor) != 2) { fprintf(stderr,"Not a valid VNC server\n"); return False; } viewer_major = rfbProtocolMajorVersion; if (server_major == 3 && server_minor >= rfbProtocolMinorVersion) { /* the server supports at least the standard protocol 3.7 */ viewer_minor = rfbProtocolMinorVersion; } else { /* any other server version, request the standard 3.3 */ viewer_minor = rfbProtocolFallbackMinorVersion; } fprintf(stderr, "Connected to RFB server, using protocol version %d.%d\n", viewer_major, viewer_minor); sprintf(pv, rfbProtocolVersionFormat, viewer_major, viewer_minor); if (!WriteExact(rfbsock, pv, sz_rfbProtocolVersionMsg)) return False; /* Read or select the security type. */ if (viewer_minor == rfbProtocolMinorVersion) { secType = SelectSecurityType(); } else { secType = ReadSecurityType(); } if (secType == rfbSecTypeInvalid) return False; switch (secType) { case rfbSecTypeNone: fprintf(stderr, "No authentication needed\n"); break; case rfbSecTypeVncAuth: if (!AuthenticateVNC()) return False; break; case rfbSecTypeTight: tightVncProtocol = True; InitCapabilities(); if (!SetupTunneling()) return False; if (!PerformAuthenticationTight()) return False; break; default: /* should never happen */ fprintf(stderr, "Internal error: Invalid security type\n"); return False; } ci.shared = (appData.shareDesktop ? 1 : 0); if (!WriteExact(rfbsock, (char *)&ci, sz_rfbClientInitMsg)) return False; if (!ReadFromRFBServer((char *)&si, sz_rfbServerInitMsg)) return False; si.framebufferWidth = Swap16IfLE(si.framebufferWidth); si.framebufferHeight = Swap16IfLE(si.framebufferHeight); si.format.redMax = Swap16IfLE(si.format.redMax); si.format.greenMax = Swap16IfLE(si.format.greenMax); si.format.blueMax = Swap16IfLE(si.format.blueMax); si.nameLength = Swap32IfLE(si.nameLength); /* FIXME: Check arguments to malloc() calls. */ desktopName = malloc(si.nameLength + 1); if (!desktopName) { fprintf(stderr, "Error allocating memory for desktop name, %lu bytes\n", (unsigned long)si.nameLength); return False; } if (!ReadFromRFBServer(desktopName, si.nameLength)) return False; desktopName[si.nameLength] = 0; fprintf(stderr,"Desktop name \"%s\"\n",desktopName); fprintf(stderr,"VNC server default format:\n"); PrintPixelFormat(&si.format); if (tightVncProtocol) { /* Read interaction capabilities (protocol 3.7t) */ if (!ReadInteractionCaps()) return False; } return True; }
Bool InitialiseRFBConnection() { rfbProtocolVersionMsg pv; int major,minor; CARD32 authScheme, reasonLen, authResult; char *reason; CARD8 challenge[CHALLENGESIZE]; char *passwd; int i; rfbClientInitMsg ci; if (!ReadFromRFBServer(pv, sz_rfbProtocolVersionMsg)) return False; pv[sz_rfbProtocolVersionMsg] = 0; if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) { fprintf(stderr,"Not a valid VNC server\n"); return False; } if (!appData.quiet) { fprintf(stderr,"VNC server supports protocol version %d.%d (viewer %d.%d)\n", major, minor, rfbProtocolMajorVersion, rfbProtocolMinorVersion); } major = rfbProtocolMajorVersion; minor = rfbProtocolMinorVersion; sprintf(pv,rfbProtocolVersionFormat,major,minor); if (!WriteToRFBServer(pv, sz_rfbProtocolVersionMsg)) return False; if (!ReadFromRFBServer((char *)&authScheme, 4)) return False; authScheme = Swap32IfLE(authScheme); switch (authScheme) { case rfbConnFailed: if (!ReadFromRFBServer((char *)&reasonLen, 4)) return False; reasonLen = Swap32IfLE(reasonLen); reason = malloc(reasonLen); if (!ReadFromRFBServer(reason, reasonLen)) return False; fprintf(stderr,"VNC connection failed: %.*s\n",(int)reasonLen, reason); return False; case rfbNoAuth: if (!appData.quiet) { fprintf(stderr,"No authentication needed\n"); } break; case rfbVncAuth: if (!ReadFromRFBServer((char *)challenge, CHALLENGESIZE)) return False; if (appData.passwordFile) { passwd = vncDecryptPasswdFromFile(appData.passwordFile); if (!passwd) { fprintf(stderr,"Cannot read valid password from file \"%s\"\n", appData.passwordFile); return False; } /* added this to read the command line password */ } else if (appData.tpass) { passwd = appData.tpass; } else { passwd = getpass("Password: "******"Reading password failed\n"); return False; } if (strlen(passwd) > 8) { passwd[8] = '\0'; } vncEncryptBytes(challenge, passwd); /* Lose the password from memory */ for (i = strlen(passwd); i >= 0; i--) { passwd[i] = '\0'; } if (!WriteToRFBServer((char *)challenge, CHALLENGESIZE)) return False; if (!ReadFromRFBServer((char *)&authResult, 4)) return False; authResult = Swap32IfLE(authResult); switch (authResult) { case rfbVncAuthOK: if (!appData.quiet) { fprintf(stderr,"VNC authentication succeeded\n"); } break; case rfbVncAuthFailed: fprintf(stderr,"VNC authentication failed\n"); return False; case rfbVncAuthTooMany: fprintf(stderr,"VNC authentication failed - too many tries\n"); return False; default: fprintf(stderr,"Unknown VNC authentication result: %d\n", (int)authResult); return False; } break; default: fprintf(stderr,"Unknown authentication scheme from VNC server: %d\n", (int)authScheme); return False; } ci.shared = 1; if (!WriteToRFBServer((char *)&ci, sz_rfbClientInitMsg)) return False; if (!ReadFromRFBServer((char *)&si, sz_rfbServerInitMsg)) return False; si.framebufferWidth = Swap16IfLE(si.framebufferWidth); si.framebufferHeight = Swap16IfLE(si.framebufferHeight); si.format.redMax = Swap16IfLE(si.format.redMax); si.format.greenMax = Swap16IfLE(si.format.greenMax); si.format.blueMax = Swap16IfLE(si.format.blueMax); si.nameLength = Swap32IfLE(si.nameLength); desktopName = malloc(si.nameLength + 1); if (!desktopName) { fprintf(stderr, "Error allocating memory for desktop name, %lu bytes\n", (unsigned long)si.nameLength); return False; } if (!ReadFromRFBServer(desktopName, si.nameLength)) return False; desktopName[si.nameLength] = 0; if (!appData.quiet) { fprintf(stderr,"Desktop name \"%s\"\n",desktopName); fprintf(stderr,"Connected to VNC server, using protocol version %d.%d\n", rfbProtocolMajorVersion, rfbProtocolMinorVersion); fprintf(stderr,"VNC server default format:\n"); PrintPixelFormat(&si.format); } return True; }
Bool InitialiseRFBConnection(int sock) { rfbProtocolVersionMsg pv; int major,minor; Bool authWillWork = True; CARD32 authScheme, reasonLen, authResult; char *reason; CARD8 challenge[CHALLENGESIZE]; char *passwd; int i; rfbClientInitMsg ci; /* if the connection is immediately closed, don't report anything, so that pmw's monitor can make test connections */ if(listenSpecified) errorMessageFromReadExact = False; if(!ReadExact(sock, pv, sz_rfbProtocolVersionMsg)) return False; errorMessageFromReadExact = True; pv[sz_rfbProtocolVersionMsg] = 0; if(sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) { fprintf(stderr,"%s: Not a valid VNC server\n",programName); return False; } fprintf(stderr,"%s: VNC server supports protocol version %d.%d " "(viewer %d.%d)\n", programName,major,minor,rfbProtocolMajorVersion, rfbProtocolMinorVersion); if((major == 3) && (minor < 3)) { /* if server is before 3.3 authentication won't work */ authWillWork = False; } else { /* any other server version, just tell it what we want */ major = rfbProtocolMajorVersion; minor = rfbProtocolMinorVersion; } sprintf(pv,rfbProtocolVersionFormat,major,minor); if(!WriteExact(sock, pv, sz_rfbProtocolVersionMsg)) return False; if(!ReadExact(sock, (char *)&authScheme, 4)) return False; authScheme = Swap32IfLE(authScheme); switch(authScheme) { case rfbConnFailed: if(!ReadExact(sock, (char *)&reasonLen, 4)) return False; reasonLen = Swap32IfLE(reasonLen); reason = malloc(reasonLen); if(!ReadExact(sock, reason, reasonLen)) { free(reason); return False; } fprintf(stderr,"%s: VNC connection failed: %.*s\n", programName, (int)reasonLen, reason); free(reason); return False; case rfbNoAuth: fprintf(stderr,"%s: No authentication needed\n",programName); break; case rfbVncAuth: if(!authWillWork) { fprintf(stderr, "\n%s: VNC server uses the old authentication scheme.\n" "You should kill your old desktop(s) and restart.\n" "If you really need to connect to this desktop use " "vncviewer3.2\n\n", programName); return False; } if(!ReadExact(sock, (char *)challenge, CHALLENGESIZE)) return False; if(passwdFile) { passwd = vncDecryptPasswdFromFile(passwdFile); if(passwd == NULL) return False; } else { passwd = passwdString; if(strlen(passwd) > 8) { passwd[8] = '\0'; } } vncEncryptBytes(challenge, passwd); /* Lose the password from memory */ for(i=0; i<strlen(passwd); i++) { passwd[i] = '\0'; } if(!WriteExact(sock, challenge, CHALLENGESIZE)) return False; if(!ReadExact(sock, (char *)&authResult, 4)) return False; authResult = Swap32IfLE(authResult); switch(authResult) { case rfbVncAuthOK: fprintf(stderr,"%s: VNC authentication succeeded\n",programName); break; case rfbVncAuthFailed: fprintf(stderr,"%s: VNC authentication failed\n",programName); return False; case rfbVncAuthTooMany: fprintf(stderr,"%s: VNC authentication failed - too many tries\n", programName); return False; default: fprintf(stderr,"%s: Unknown VNC authentication result: %d\n", programName,(int)authResult); return False; } break; default: fprintf(stderr, "%s: Unknown authentication scheme from VNC server: %d\n", programName,(int)authScheme); return False; } ci.shared = (shareDesktop ? 1 : 0); if(!WriteExact(sock, (char *)&ci, sz_rfbClientInitMsg)) return False; if(!ReadExact(sock, (char *)&si, sz_rfbServerInitMsg)) return False; si.framebufferWidth = Swap16IfLE(si.framebufferWidth); si.framebufferHeight = Swap16IfLE(si.framebufferHeight); si.format.redMax = Swap16IfLE(si.format.redMax); si.format.greenMax = Swap16IfLE(si.format.greenMax); si.format.blueMax = Swap16IfLE(si.format.blueMax); si.nameLength = Swap32IfLE(si.nameLength); desktopName = malloc(si.nameLength + 1); if(!ReadExact(sock, desktopName, si.nameLength)) { free(desktopName); return False; } desktopName[si.nameLength] = 0; fprintf(stderr,"%s: Desktop name \"%s\"\n",programName,desktopName); free(desktopName); fprintf(stderr, "%s: Connected to VNC server, using protocol version %d.%d\n", programName, rfbProtocolMajorVersion, rfbProtocolMinorVersion); fprintf(stderr,"%s: VNC server default format:\n",programName); PrintPixelFormat(&si.format); return True; }
void Graphics2D::PrintVideoInfo( ) { Assert( ::SDL_WasInit( SDL_INIT_VIDEO ) != 0 ); char driverName[ 50 ] = ""; char * name = ::SDL_VideoDriverName( driverName, 50 ); Assert( name ); cout << "Video driver: " << driverName << endl; bool videoModeSet = (m_spScreenSurface != 0); const ::SDL_VideoInfo * videoInfo = ::SDL_GetVideoInfo( ); cout << "Can create hardware surfaces? " << (videoInfo->hw_available ? "yes" : "no") << endl; cout << "Window manager available? " << (videoInfo->wm_available ? "yes" : "no") << endl; cout << "HW to HW blits accelerated? " << (videoInfo->blit_hw ? "yes" : "no") << endl; cout << "HW to HW colorkey blits accelerated? " << (videoInfo->blit_hw_CC ? "yes" : "no") << endl; cout << "HW to HW alpha blits accelerated? " << (videoInfo->blit_hw_A ? "yes" : "no") << endl; cout << "SW to HW blits accelerated? " << (videoInfo->blit_sw ? "yes" : "no") << endl; cout << "SW to HW colorkey blits accelerated? " << (videoInfo->blit_sw_CC ? "yes" : "no") << endl; cout << "SW to HW alpha blits accelerated? " << (videoInfo->blit_sw_A ? "yes" : "no") << endl; cout << "Color fills accelerated? " << (videoInfo->blit_fill ? "yes" : "no") << endl; cout << "Video memory: " << videoInfo->video_mem << endl; if ( videoModeSet ) { char * title; char * icon; ::SDL_WM_GetCaption( &title, &icon ); if ( title ) cout << "Window title: \"" << title << "\"" << endl; if ( icon ) cout << "Window icon: \"" << icon << "\"" << endl; cout << "Screen surface:" << endl; Screen()->PrintInfo( ); } else { PrintPixelFormat( *(videoInfo->vfmt) ); cout << "Available resolutions for this pixel format" << endl; Uint32 flags = SDL_FULLSCREEN | SDL_HWSURFACE; cout << " (SDL_FULLSCREEN | SDL_HWSURFACE):" << endl; PrintAvailableResolutions( *(videoInfo->vfmt), flags ); flags = SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF; cout << " (SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF):" << endl; PrintAvailableResolutions( *(videoInfo->vfmt), flags ); flags = SDL_OPENGL; cout << " (SDL_OPENGL)" << endl; PrintAvailableResolutions( *(videoInfo->vfmt), flags ); for ( int i = 0; i < NumPixelTypes; ++i ) { ::SDL_PixelFormat format = DetermineSDLPixelFormat( (EPixelType) i ); cout << "Available resolutions for " << GetPixelTypeName( (EPixelType) i ) << endl; flags = SDL_HWSURFACE; cout << " (SDL_HWSURFACE):" << endl; PrintAvailableResolutions( format, flags ); flags = SDL_HWSURFACE | SDL_DOUBLEBUF; cout << " (SDL_HWSURFACE | SDL_DOUBLEBUF):" << endl; PrintAvailableResolutions( format, flags ); flags = SDL_FULLSCREEN | SDL_HWSURFACE; cout << " (SDL_FULLSCREEN | SDL_HWSURFACE):" << endl; PrintAvailableResolutions( format, flags ); flags = SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF; cout << " (SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF):" << endl; PrintAvailableResolutions( format, flags ); flags = SDL_OPENGL; cout << " (SDL_OPENGL)" << endl; PrintAvailableResolutions( format, flags ); } } }