本文整理汇总了C++中Surface类的典型用法代码示例。如果您正苦于以下问题:C++ Surface类的具体用法?C++ Surface怎么用?C++ Surface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Surface类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPlayerStats
// drawPlayerStats
//---------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------
void RankView::drawPlayerStats(const Surface &dest)
{
char statBuf[256];
iXY offset;
iXY flagOffset;
//int index;
Stats::setSortOrder( _stats_sort_order_game_type );
Stats::Initialize();
char playerFlagIndex;
short playerKills;
short playerLosses;
short playerTotalPoints;
short playerObjectives;
char *playerName;
int playerStatsDisplayType;
int numPlayers = Stats::getActivePlayers();
//int offsetRunner = getScrollBarTopItem() - numPlayers;
// Scoot through the list to the first visible player, since we can't seek to an index yet.
//while(offsetRunner > 0)
//{
// offsetRunner--;
// Stats::GetPlayerStats(playerFlagName, &playerKills, &playerLosses, &playerTotalPoints, &playerName);
//}
//
//setScrollBarViewableCount(viewableMessageCount);
//setScrollBarItemCount(numPlayers);
//
//int numToDraw = (viewableMessageCount < numPlayers) ? viewableMessageCount : numPlayers;
//
//if(numPlayers < viewableMessageCount)
//{
// setScrollBarTopItem(numPlayers);
//} else
//{
// setScrollBarTopItem(numPlayers - viewableMessageCount);
//}
for (int i = 0; i < numPlayers; i++)
{
offset.x = 2;
flagOffset.x = offset.x + 160;
offset.y = 40 + i * (CHAR_YPIX + (UNIT_FLAGS_SURFACE.getPixY() - CHAR_YPIX) );
flagOffset.y = (40 - (UNIT_FLAGS_SURFACE.getPixY() - CHAR_YPIX)/2 ) + i * UNIT_FLAGS_SURFACE.getPixY();
//index = getScrollBarTopItem() + i;
//assert(index < numPlayers);
Stats::GetPlayerStats(&playerFlagIndex,
&playerKills,
&playerLosses,
&playerTotalPoints,
&playerObjectives,
&playerName,
&playerStatsDisplayType);
// Add player flag name.
sprintf(statBuf, "%-20s%10i%7i%6i%10i", playerName, playerKills, playerLosses, playerTotalPoints, playerObjectives );
if (statBuf != 0)
{
PIX color;
switch( playerStatsDisplayType )
{
case _stats_display_type_local_player :
color = Color::blue;
break;
case _stats_display_type_ally :
color = Color::orange;
break;
case _stats_display_type_default :
color = Color::white;
break;
} // ** switch
dest.bltString( offset.x, offset.y, statBuf, color );
}
UNIT_FLAGS_SURFACE.setFrame( playerFlagIndex );
UNIT_FLAGS_SURFACE.blt( dest, flagOffset.x, flagOffset.y );
}
} // end RankView::drawPlayerStats
示例2: draw
/**
* Draws the view of all the facilities in the base, connectors
* between them and crafts landed in hangars.
*/
void BaseView::draw()
{
Surface::draw();
// Draw grid squares
for (int x = 0; x < BASE_SIZE; ++x)
{
for (int y = 0; y < BASE_SIZE; ++y)
{
Surface *frame = _texture->getFrame(0);
frame->setX(x * GRID_SIZE);
frame->setY(y * GRID_SIZE);
frame->blit(this);
}
}
std::vector<Craft*>::iterator craft = _base->getCrafts()->begin();
for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i)
{
// Draw facility shape
int num = 0;
for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y)
{
for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x)
{
Surface *frame;
int outline = std::max((*i)->getRules()->getSize() * (*i)->getRules()->getSize(), 3);
if ((*i)->getBuildTime() == 0)
frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num);
else
frame = _texture->getFrame((*i)->getRules()->getSpriteShape() + num + outline);
frame->setX(x * GRID_SIZE);
frame->setY(y * GRID_SIZE);
frame->blit(this);
num++;
}
}
}
for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i)
{
// Draw connectors
if ((*i)->getBuildTime() == 0)
{
// Facilities to the right
int x = (*i)->getX() + (*i)->getRules()->getSize();
if (x < BASE_SIZE)
{
for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y)
{
if (_facilities[x][y] != 0 && _facilities[x][y]->getBuildTime() == 0)
{
Surface *frame = _texture->getFrame(7);
frame->setX(x * GRID_SIZE - GRID_SIZE / 2);
frame->setY(y * GRID_SIZE);
frame->blit(this);
}
}
}
// Facilities to the bottom
int y = (*i)->getY() + (*i)->getRules()->getSize();
if (y < BASE_SIZE)
{
for (int subX = (*i)->getX(); subX < (*i)->getX() + (*i)->getRules()->getSize(); ++subX)
{
if (_facilities[subX][y] != 0 && _facilities[subX][y]->getBuildTime() == 0)
{
Surface *frame = _texture->getFrame(8);
frame->setX(subX * GRID_SIZE);
frame->setY(y * GRID_SIZE - GRID_SIZE / 2);
frame->blit(this);
}
}
}
}
}
for (std::vector<BaseFacility*>::iterator i = _base->getFacilities()->begin(); i != _base->getFacilities()->end(); ++i)
{
// Draw facility graphic
int num = 0;
for (int y = (*i)->getY(); y < (*i)->getY() + (*i)->getRules()->getSize(); ++y)
{
for (int x = (*i)->getX(); x < (*i)->getX() + (*i)->getRules()->getSize(); ++x)
{
if ((*i)->getRules()->getSize() == 1)
{
Surface *frame = _texture->getFrame((*i)->getRules()->getSpriteFacility() + num);
frame->setX(x * GRID_SIZE);
frame->setY(y * GRID_SIZE);
frame->blit(this);
//.........这里部分代码省略.........
示例3:
void bakersc3Starbucks::update(){
(*texture).update(*mySurface, mySurface->getBounds());
}
示例4: AccessByItk_3
void HeightFieldSurfaceClipImageFilter::GenerateData()
{
const Image *inputImage = this->GetInput( 0 );
const Image *outputImage = this->GetOutput();
m_InputTimeSelector->SetInput( inputImage );
m_OutputTimeSelector->SetInput( outputImage );
Image::RegionType outputRegion = outputImage->GetRequestedRegion();
const TimeGeometry *outputTimeGeometry = outputImage->GetTimeGeometry();
const TimeGeometry *inputTimeGeometry = inputImage->GetTimeGeometry();
ScalarType timeInMS;
int timestep = 0;
int tstart = outputRegion.GetIndex( 3 );
int tmax = tstart + outputRegion.GetSize( 3 );
for (unsigned int i = 1; i < this->GetNumberOfInputs(); ++i)
{
Surface *inputSurface = const_cast< Surface * >(
dynamic_cast< Surface * >( itk::ProcessObject::GetInput( i ) ) );
if ( !outputImage->IsInitialized() || inputSurface == NULL )
return;
MITK_INFO<<"Plane: "<<i;
MITK_INFO << "Clipping: Start\n";
//const Geometry2D *clippingGeometryOfCurrentTimeStep = NULL;
int t;
for( t = tstart; t < tmax; ++t )
{
timeInMS = outputTimeGeometry->TimeStepToTimePoint( t );
timestep = inputTimeGeometry->TimePointToTimeStep( timeInMS );
m_InputTimeSelector->SetTimeNr( timestep );
m_InputTimeSelector->UpdateLargestPossibleRegion();
m_OutputTimeSelector->SetTimeNr( t );
m_OutputTimeSelector->UpdateLargestPossibleRegion();
// Compose IndexToWorld transform of image with WorldToIndexTransform of
// clipping data for conversion from image index space to plane index space
AffineTransform3D::Pointer planeWorldToIndexTransform = AffineTransform3D::New();
inputSurface->GetGeometry( t )->GetIndexToWorldTransform()
->GetInverse( planeWorldToIndexTransform );
AffineTransform3D::Pointer imageToPlaneTransform =
AffineTransform3D::New();
imageToPlaneTransform->SetIdentity();
imageToPlaneTransform->Compose(
inputTimeGeometry->GetGeometryForTimeStep( t )->GetIndexToWorldTransform() );
imageToPlaneTransform->Compose( planeWorldToIndexTransform );
MITK_INFO << "Accessing ITK function...\n";
if(i==1)
{
AccessByItk_3(
m_InputTimeSelector->GetOutput(),
_InternalComputeClippedImage,
this,
inputSurface->GetVtkPolyData( t ),
imageToPlaneTransform );
}
else
{
mitk::Image::Pointer extensionImage = m_OutputTimeSelector->GetOutput()->Clone();
AccessByItk_3(
extensionImage,
_InternalComputeClippedImage,
this,
inputSurface->GetVtkPolyData( t ),
imageToPlaneTransform );
}
if (m_ClippingMode == CLIPPING_MODE_MULTIPLANE)
m_MultiPlaneValue = m_MultiPlaneValue*2;
}
}
m_TimeOfHeaderInitialization.Modified();
}
示例5: loadSurfacetoVram
bool loadSurfacetoVram(Surface & surface, GLuint & tex_id, Rect & tex_rect)
{
int neww = surface.w;
int newh = surface.h;
// Check that the image's width is a power of 2
if ( (surface.w & (surface.w - 1)) != 0 ) {
neww = 1 << (int)ceil(log2(surface.w));
}
// Also check if the height is a power of 2
if ( (surface.h & (surface.h - 1)) != 0 ) {
newh = 1 << (int)ceil(log2(surface.h));
}
tex_rect.w = neww;
tex_rect.h = newh;
/* Resize if needed */
if (neww !=surface.w || newh !=surface.h)
{
Surface q;
q.set(new tRGBA [neww*newh], neww, newh);
memset(q.pixels, 0, neww*newh*sizeof(tRGBA));
tRGBA * src = surface.pixels;
tRGBA * dst = q.pixels;
for (int y=0; y<surface.h; ++y)
{
for (int x=0; x<surface.w; ++x)
{
*dst = *src;
++dst; ++src;
}
dst+=neww - surface.w;
}
surface.clean();
surface = q;
}
// Have OpenGL generate a texture object handle for us
glGenTextures( 1, &tex_id );
if (glGetError())
cout << "GL error" << glGetError() << endl;
// Bind the texture object
glActiveTexture(GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, tex_id );
// Set the texture's stretching properties
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
// Edit the texture object's image data using the information SDL_Surface gives us
glTexImage2D( GL_TEXTURE_2D, 0, 4, surface.w, surface.h, 0,
GL_RGBA, GL_UNSIGNED_BYTE, surface.pixels );
return true;
}
示例6: insideSurfaceClosest
bool insideSurfaceClosest(const Point3D &pTest, const Surface &s, const SpacialHash &faceHash, ClosestPointInfo *inf, float stopBelow, bool allowQuickTest){
if (inf)
inf->type = DIST_TYPE_INVALID;
// quick bounding box test
if (allowQuickTest){
if (pTest.x < s.pMin.x || pTest.x > s.pMax.x ||
pTest.y < s.pMin.y || pTest.y > s.pMax.y ||
pTest.z < s.pMin.z || pTest.z > s.pMax.z){
return false;
}
}
ClosestPointInfo localClosestInf;
if (!inf)
inf = &localClosestInf;
float dist = getClosestPoint(inf, pTest, s, faceHash, stopBelow);
if (dist < stopBelow){
// optimise for dodec
return true;
}
// vector to point on surface
Vector3D v;
v.difference(pTest, inf->pClose);
v.norm();
if (inf->type == FACE){
// face test
Vector3D n;
s.getTriangleNormal(&n, inf->triangle);
double dt = n.dot(v);
return dt <= 0;
}
else if (inf->type == EDGE){
// edge test
const Surface::Triangle *tri = &s.triangles.index(inf->triangle);
// edge will be between vertices v[num] and v[(num+1)%3]
int e[2];
e[0] = tri->v[inf->num];
e[1] = tri->v[(inf->num+1)%3];
int neigh = findNeighbour(s, *tri, e);
if (neigh >= 0){
// make a plane for one of the triangles
Vector3D n1;
s.getTriangleNormal(&n1, inf->triangle);
Point3D p1 = s.vertices.index(e[0]).p;
Plane pl1;
pl1.assign(n1, p1);
// get the point from the other triangle which is not part of edge
const Surface::Triangle *tri2 = &s.triangles.index(neigh);
for (int i = 0; i < 3; i++){
if (tri2->v[i] != e[0] && tri2->v[i] != e[1])
break;
}
CHECK_DEBUG0(i != 3);
Point3D p2 = s.vertices.index(e[1]).p;
// get signed distance to plane
float dist = pl1.dist(p2);
// need normal for second triangle
Vector3D n2;
s.getTriangleNormal(&n2, neigh);
if (dist <= 0.0f){
// faces form convex spike, back facing to both
return v.dot(n1) <= 0 && v.dot(n2) <= 0;
}
else{
// faces form concavity, back facing to either
return v.dot(n1) <= 0 || v.dot(n2) <= 0;
}
}
else{
OUTPUTINFO("HHHHHMMMMMMM loose edge\n");
return false; // only one triangle on edge - use face ??
}
}
else{// if (minType == VERTEX)
// chosen triangle
const Surface::Triangle *tri = &s.triangles.index(inf->triangle);
// chosen vertex
int vI = tri->v[inf->num];
Vector3D n;
s.getVertexNormal(&n, vI);
return n.dot(v) <= 0;
/*
// get all faces
Array<int> tris;
s.findNeighbours(&tris, vI, inf->triangle);
// behind test for all faces
int numTri = tris.getSize();
//.........这里部分代码省略.........
示例7: ray
glm::vec3 Ray::trace(glm::vec3 rayOrig, glm::vec3 rayDir, float depth, int bounces) {
// ----------------------------------------------
// Compare ray with every object in scene
// Find the smallest distance to an object
// ----------------------------------------------
float t0, t1, tNear = INF;
Surface *s = nullptr; // Pointer to closest object
for (auto &o : *scene->objects) {
if (o->intersects(rayOrig, rayDir, t0, t1)) {
if (t0 < tNear) {
tNear = t0;
s = o;
}
}
}
// ----------------------------------------------
// We have found an object
// ----------------------------------------------
if (s != nullptr) {
// If the closes object is a light, return light color
if (s->isLight())
return s->color;
// p is the point of intersection
glm::vec3 directIllumination (0.0);
glm::vec3 indirectIllumination (0.0);
glm::vec3 p = rayOrig + rayDir * tNear;
glm::vec3 normal = s->getNormal(p);
glm::vec3 r = rayDir - 2 * glm::dot(rayDir, normal) * normal; // reflected direction
// ----------------------------------------------
// Indirect illumination
// If the object is reflective or refractive, calculate new ray(s)
// ----------------------------------------------
if (s->isRefractive()) {
// If the object is refractive, create refractive ray
// Calculate new refractive ray
// Need to do a flip if we are inside the object
//glm::vec3 n = normal;
//const float index = 1/1.5;
//Sphere *temp = static_cast <Sphere*>(s);
//if (glm::length(temp->getCenter() - p) < temp->getRadius()) n = -n;
//glm::vec3 t = glm::normalize(glm::refract(rayDir, n, index));
Ray ray(scene);
//indirectIllumination += ray.trace(p, t, depth, bounces);
// Calculate reflective ray for both refracive and reflective materials
// Trace reflective ray
indirectIllumination += ray.trace(p, r, depth, bounces++);
indirectIllumination /= (float)bounces;
}
// ----------------------------------------------
// Indirect illumination
// Material is diffuse, do Monte Carlo stuff
// ----------------------------------------------
else if(bounces < scene->maxBounces) {
// Russian roulette
float r1 = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
float r2 = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
float absorption = 0.5;
// Ray is scattered
if (static_cast <float> (rand()) / static_cast <float> (RAND_MAX) > absorption) {
// New random direction over hemisphere
float inclination = 2.0 * M_PI * r1;
float azimuth = acos(2.0 * r2 - 1.0);
float u = cos(azimuth);
float x = sqrt(1 - u * u) * cos(inclination);
float y = sqrt(1 - u * u) * sin(inclination);
float z = u;
// New direction. If it points the wrong way, change direction
glm::vec3 newDir(x, y, z);
if (glm::dot(normal, newDir) < 0) newDir = -newDir;
// pdf - over hemisphere
// cos - relationship between normal and the direction reflected light will come from
// BRDF - Lambertian or Oren-Nayar
float pdf = 1.0 / 2.0 * M_PI;
float cos = glm::dot(normal, newDir);
float BRDF = s->isOren() ? OrenNayarBRDF(newDir, glm::normalize(-scene->cameraDir), normal) : glm::dot(normal, newDir);
Ray ray(scene);
indirectIllumination = ray.trace(p, newDir, depth, bounces++) * cos * BRDF / pdf;
indirectIllumination /= ((1 - absorption));
}
}
//.........这里部分代码省略.........
示例8: getWidth
/**
* Draws all the characters in the text with a really
* nasty complex gritty text rendering algorithm logic stuff.
*/
void Text::draw()
{
Surface::draw();
if (_text.empty() || _font == 0)
{
return;
}
// Show text borders for debugging
if (Options::getBool("debugUi"))
{
SDL_Rect r;
r.w = getWidth();
r.h = getHeight();
r.x = 0;
r.y = 0;
this->drawRect(&r, 5);
r.w-=2;
r.h-=2;
r.x++;
r.y++;
this->drawRect(&r, 0);
}
int x = 0, y = 0, line = 0, height = 0;
Font *font = _font;
int color = _color;
std::wstring *s = &_text;
for (std::vector<int>::iterator i = _lineHeight.begin(); i != _lineHeight.end(); ++i)
{
height += *i;
}
switch (_valign)
{
case ALIGN_TOP:
y = 0;
break;
case ALIGN_MIDDLE:
y = (int)ceil((getHeight() - height) / 2.0);
break;
case ALIGN_BOTTOM:
y = getHeight() - height;
break;
}
x = getLineX(line);
if (_wrap)
{
s = &_wrappedText;
}
// Set up text color
int mul = 1;
if (_contrast)
{
mul = 3;
}
// Set up text direction
int dir = 1;
if (_lang->getTextDirection() == DIRECTION_RTL)
{
dir = -1;
}
// Invert text by inverting the font palette on index 3 (font palettes use indices 1-5)
int mid = _invert ? 3 : 0;
// Draw each letter one by one
for (std::wstring::iterator c = s->begin(); c != s->end(); ++c)
{
if (Font::isSpace(*c))
{
x += dir * font->getCharSize(*c).w;
}
else if (Font::isLinebreak(*c))
{
line++;
y += font->getCharSize(*c).h;
x = getLineX(line);
if (*c == L'\x02')
{
font = _small;
}
}
else if (*c == L'\x01')
{
color = (color == _color ? _color2 : _color);
}
else
{
if (dir < 0)
x += dir * font->getCharSize(*c).w;
//.........这里部分代码省略.........
示例9: switch
bool AffineInteractor3D
::ExecuteAction( Action *action, StateEvent const *stateEvent )
{
bool ok = false;
// Get data object
BaseData *data = m_DataNode->GetData();
if ( data == NULL )
{
MITK_ERROR << "No data object present!";
return ok;
}
// Get Event and extract renderer
const Event *event = stateEvent->GetEvent();
BaseRenderer *renderer = NULL;
vtkRenderWindow *renderWindow = NULL;
vtkRenderWindowInteractor *renderWindowInteractor = NULL;
vtkRenderer *currentVtkRenderer = NULL;
vtkCamera *camera = NULL;
if ( event != NULL )
{
renderer = event->GetSender();
if ( renderer != NULL )
{
renderWindow = renderer->GetRenderWindow();
if ( renderWindow != NULL )
{
renderWindowInteractor = renderWindow->GetInteractor();
if ( renderWindowInteractor != NULL )
{
currentVtkRenderer = renderWindowInteractor
->GetInteractorStyle()->GetCurrentRenderer();
if ( currentVtkRenderer != NULL )
{
camera = currentVtkRenderer->GetActiveCamera();
}
}
}
}
}
// Check if we have a DisplayPositionEvent
const DisplayPositionEvent *dpe =
dynamic_cast< const DisplayPositionEvent * >( stateEvent->GetEvent() );
if ( dpe != NULL )
{
m_CurrentPickedPoint = dpe->GetWorldPosition();
m_CurrentPickedDisplayPoint = dpe->GetDisplayPosition();
}
// Get the timestep to also support 3D+t
int timeStep = 0;
ScalarType timeInMS = 0.0;
if ( renderer != NULL )
{
timeStep = renderer->GetTimeStep( data );
timeInMS = renderer->GetTime();
}
// If data is an mitk::Surface, extract it
Surface *surface = dynamic_cast< Surface * >( data );
vtkPolyData *polyData = NULL;
if ( surface != NULL )
{
polyData = surface->GetVtkPolyData( timeStep );
// Extract surface normal from surface (if existent, otherwise use default)
vtkPointData *pointData = polyData->GetPointData();
if ( pointData != NULL )
{
vtkDataArray *normal = polyData->GetPointData()->GetVectors( "planeNormal" );
if ( normal != NULL )
{
m_ObjectNormal[0] = normal->GetComponent( 0, 0 );
m_ObjectNormal[1] = normal->GetComponent( 0, 1 );
m_ObjectNormal[2] = normal->GetComponent( 0, 2 );
}
}
}
// Get geometry object
m_Geometry = data->GetGeometry( timeStep );
// Make sure that the data (if time-resolved) has enough entries;
// if not, create the required extra ones (empty)
data->Expand( timeStep+1 );
switch (action->GetActionId())
{
case AcDONOTHING:
ok = true;
break;
case AcCHECKOBJECT:
{
//.........这里部分代码省略.........
示例10: AssertFatal
//------------------------------------------------------------------------------
//--------------------------------------
// Object proper...
//--------------------------------------
//
Surface*
Surface::create(HWND io_clientWnd,
const Int32 in_width,
const Int32 in_height)
{
// Must return a new OpenGL::Surface* of resolution closest to in_w/h.
// Should also activate the device.
//
AssertFatal(io_clientWnd != NULL, "No client window handle");
Surface* pRetSurf = new Surface;
#ifndef DEBUG
BOOL test = TRUE;
bool found = false;
UInt32 modeNum = 0;
DEVMODE devMode;
while (test == TRUE) {
memset(&devMode, 0, sizeof(devMode));
devMode.dmSize = sizeof(devMode);
test = EnumDisplaySettings(NULL, modeNum, &devMode);
if (devMode.dmPelsWidth == (UInt32)in_width &&
devMode.dmPelsHeight == (UInt32)in_height) {
found = true;
}
modeNum++;
}
if (found == false) {
delete pRetSurf;
return NULL;
}
// Change the window position
AssertMessage(false, avar("Changing window style (%d, %d)", in_width, in_height));
GetWindowRect(io_clientWnd, &pRetSurf->m_oldWindowRect);
LONG style = GetWindowLong(io_clientWnd, GWL_STYLE);
style &= ~(WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
SetWindowLong(io_clientWnd, GWL_STYLE, style);
LONG exStyle = GetWindowLong(io_clientWnd, GWL_EXSTYLE);
exStyle |= WS_EX_TOPMOST;
SetWindowLong(io_clientWnd, GWL_EXSTYLE, exStyle);
BOOL posSuccess = SetWindowPos(io_clientWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
AssertFatal(posSuccess == TRUE, "Error setting pos");
// Annnnd, set the new display mode. Desktop icons?
//
memset(&devMode, 0, sizeof(devMode));
devMode.dmSize = sizeof(devMode);
devMode.dmPelsWidth = in_width;
devMode.dmPelsHeight = in_height;
devMode.dmFields = DM_PELSWIDTH |
DM_PELSHEIGHT;
#if 1
AssertMessage(false, avar("Changing display settings: (%d, %d)", devMode.dmPelsWidth, devMode.dmPelsHeight));
ChangeDisplaySettings(&devMode, CDS_FULLSCREEN);
VidModeChecker::sm_theInstance.changedDisplaySettings();
#endif
SetForegroundWindow(io_clientWnd);
posSuccess = SetWindowPos(io_clientWnd, HWND_TOPMOST, 0, 0, in_width, in_height, SWP_FRAMECHANGED);
AssertFatal(posSuccess == TRUE, "Error setting pos");
pRetSurf->m_windowStyleChanged = true;
#endif
pRetSurf->m_hWnd = io_clientWnd;
pRetSurf->m_hDC = GetDC(pRetSurf->m_hWnd);
if (pRetSurf->m_hDC == NULL) {
AssertWarn(0, "Unable to get a DC for the window");
delete pRetSurf;
return NULL;
}
// Set the Pixel format, first retrieving the old format
//
pRetSurf->m_oldPixelFormat = GetPixelFormat(pRetSurf->m_hDC);
DescribePixelFormat(pRetSurf->m_hDC, pRetSurf->m_oldPixelFormat,
sizeof(PIXELFORMATDESCRIPTOR),
&pRetSurf->m_oldPixelFormatDescriptor);
int chosenPixelFormat;
PIXELFORMATDESCRIPTOR chosenPFD;
if (pRetSurf->choosePixelFormat(chosenPixelFormat,
chosenPFD,
pRetSurf->m_hWnd,
pRetSurf->m_hDC) == false) {
AssertWarn(0, "Unable to choose a pixel format");
delete pRetSurf;
return NULL;
}
//.........这里部分代码省略.........
示例11: Blit
void Renderer::Blit(Surface &surf, SDL_Rect *src, SDL_Rect *dest)
{
SDL_RenderCopy(Get(), surf.GetTexture(), src, dest);
}
示例12: sourceDesc
char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight,
int16 x, int16 y, int16 transp, Surface &destDesc) {
byte *memBuffer;
byte *srcPtr;
byte temp;
uint32 sourceLeft;
uint16 cmdVar;
int16 curWidth, curHeight;
int16 offset;
int16 counter2;
int16 bufPos;
int16 strLen;
int16 lenCmd;
//_vm->validateVideoMode(destDesc._vidMode);
if (sprBuf[0] != 1)
return 0;
if (sprBuf[1] != 2)
return 0;
if (sprBuf[2] == 2) {
Surface sourceDesc(srcWidth, srcHeight, 1, sprBuf + 3);
destDesc.blit(sourceDesc, 0, 0, srcWidth - 1, srcHeight - 1, x, y, (transp == 0) ? -1 : 0);
return 1;
} else if (sprBuf[2] == 1) {
memBuffer = new byte[4370];
assert(memBuffer);
memset(memBuffer, 0, 4370);
srcPtr = sprBuf + 3;
sourceLeft = READ_LE_UINT32(srcPtr);
Pixel destPtr = destDesc.get(x, y);
curWidth = 0;
curHeight = 0;
Pixel linePtr = destPtr;
srcPtr += 4;
if ((READ_LE_UINT16(srcPtr) == 0x1234) && (READ_LE_UINT16(srcPtr + 2) == 0x5678)) {
srcPtr += 4;
bufPos = 273;
lenCmd = 18;
} else {
lenCmd = 100;
bufPos = 4078;
}
memset(memBuffer, 32, bufPos);
cmdVar = 0;
while (1) {
cmdVar >>= 1;
if ((cmdVar & 0x100) == 0)
cmdVar = *srcPtr++ | 0xFF00;
if ((cmdVar & 1) != 0) {
temp = *srcPtr++;
if ((temp != 0) || (transp == 0))
destPtr.set(temp);
destPtr++;
curWidth++;
if (curWidth >= srcWidth) {
curWidth = 0;
linePtr += destDesc.getWidth();
destPtr = linePtr;
if (++curHeight >= srcHeight)
break;
}
memBuffer[bufPos] = temp;
bufPos = (bufPos + 1) % 4096;
if (--sourceLeft == 0)
break;
} else {
offset = *srcPtr++;
temp = *srcPtr++;
offset |= (temp & 0xF0) << 4;
strLen = (temp & 0x0F) + 3;
if (strLen == lenCmd)
strLen = *srcPtr++ + 18;
for (counter2 = 0; counter2 < strLen; counter2++) {
temp = memBuffer[(offset + counter2) % 4096];
if ((temp != 0) || (transp == 0))
destPtr.set(temp);
//.........这里部分代码省略.........