Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
srcW = this->src_rect.width srcH = this->src_rect.height glLoadIdentity(); glTranslated(this->x,this->y,0); glScaled(srcW,srcH,0); glBegin(GL_QUADS); glTexCoord2f(static_cast<float> (this->src_rect.x) / texW, static_cast<float> (this->src_rect.y) / texH); glVertex3d(0.0f,0.0f,this->z); glTexCoord2f(static_cast<float> (srcW+this->src_rect.x) / texW, static_cast<float> (this->src_rect.y) / texH); glVertex3d(1.0f,0.0f,this->z); glTexCoord2f(static_cast<float> (srcW+this->src_rect.x) / texW, static_cast<float> (srcH+this->src_rect.y) / texH); glVertex3d(1.0f,1.0f,this->z); glTexCoord2f(static_cast<float> (this->src_rect.x) / texW, static_cast<float> (srcH+this->src_rect.y) / texH); glVertex3d(0.0f,1.0f,this->z ; glEnd(); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
srcW = this->src_rect.width srcH = this->src_rect.height glLoadIdentity(); glTranslated(this->x,this->y,0); glScaled(srcW-this->src_rect.x,srcH-this->src_rect.y,0); glBegin(GL_QUADS); glTexCoord2f(static_cast<float> (this->src_rect.x) / texW, static_cast<float> (this->src_rect.y) / texH); glVertex3d(0.0f,0.0f,this->z); glTexCoord2f(static_cast<float> (srcW) / texW, static_cast<float> (this->src_rect.y) / texH); glVertex3d(1.0f,0.0f,this->z); glTexCoord2f(static_cast<float> (srcW) / texW, static_cast<float> (srcH) / texH); glVertex3d(1.0f,1.0f,this->z); glTexCoord2f(static_cast<float> (this->src_rect.x) / texW, static_cast<float> (srcH) / texH); glVertex3d(0.0f,1.0f,this->z ; glEnd(); |
Zitat
zeigt er die texture wiederholt an der (0|0) stelle an
200+100 = über der texture grösse,texture wird ab da von neu angezeigt
und das will ich nicht
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
float invw = 1.0f / g_pTex->GetWidth(); float invh = 1.0f / g_pTex->GetHeight(); float cx0 = Clamp( 0.0f, 1.0f, rect.x * invw ); float cy0 = Clamp( 0.0f, 1.0f, rect.y * invh ); float cx1 = Clamp( 0.0f, 1.0f, ( rect.x + rect.w ) * invw ); float cy1 = Clamp( 0.0f, 1.0f, ( rect.y + rect.h ) * invh ); if ( cx0 > cx1 ) Swap( cx0, cx1 ); if ( cy0 > cy1 ) Swap( cy0, cy1 ); glBegin( GL_QUADS ); glTexCoord2f( cx0, cy0 ); glVertex2f( -1.0f, 1.0f ); glTexCoord2f( cx0, cy1 ); glVertex2f( -1.0f, -1.0f ); glTexCoord2f( cx1, cy1 ); glVertex2f( 1.0f, -1.0f ); glTexCoord2f( cx1, cy0 ); glVertex2f( 1.0f, 1.0f ); glEnd(); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#define CLAMP(X,Min,Max) if( X > Max ){ X = Max;}else if( X < Min ){X = Min;} float invW = 1.0f / static_cast<float>(texW); float invH = 1.0f / static_cast<float>(texH); clampf cx = 0.0f; CLAMP( cx, 1.0f, this->src_rect.x * invW ); clampf cy = 0.0f; CLAMP( cy, 1.0f, this->src_rect.y * invH ); clampf cwidth = 0.0f; CLAMP( cwidth, 1.0f, static_cast<float>(( this->src_rect.x + this->src_rect.width ) * invW) ); clampf cheight = 0.0f; CLAMP( cheight, 1.0f, static_cast<float>(( this->src_rect.y + this->src_rect.height ) * invH) ); if ( cx > cwidth ) std::swap( cx, cwidth ); if ( cy > cwidth ) std::swap( cy, cheight ); glLoadIdentity(); glTranslated(this->x,this->y); glScalef(this->src_rect.height,this->src_rect.height,0); glBegin(GL_QUADS); glTexCoord2f(cx,cy); glColor4ub(this->vColor[0].red,this->vColor[0].green,this->vColor[0].blue,this->vColor[0].alpha); glVertex3f(-1.0f, 1.0f,this->z); glTexCoord2f(cx,cheight); glColor4ub(this->vColor[1].red,this->vColor[1].green,this->vColor[1].blue,this->vColor[1].alpha); glVertex3f(-1.0f, -1.0f,this->z); glTexCoord2f(cwidth,cheight); glColor4ub(this->vColor[2].red,this->vColor[2].green,this->vColor[2].blue,this->vColor[2].alpha); glVertex3f(1.0f, -1.0f,this->z); glTexCoord2f(cwidth,cy); glColor4ub(this->vColor[3].red,this->vColor[3].green,this->vColor[3].blue,this->vColor[3].alpha); glVertex3f(-1.0f, 1.0f,this->z); glEnd(); |
C-/C++-Quelltext |
|
1 |
#define CLAMP(X,Min,Max) if( X > Max ){ X = Max;}else if( X < Min ){X = Min;} |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 |
clampf cx = this->src_rect.x * invW; CLAMP( cx, 0.0f, 1.0f ); |
C-/C++-Quelltext |
|
1 2 3 4 |
glBegin( GL_QUADS ); glTexCoord2f( cx0, cy0 ); glVertex2f( -1.0f, 1.0f ); glTexCoord2f( cx0, cy1 ); glVertex2f( -1.0f, -1.0f ); //... |
C-/C++-Quelltext |
|
1 2 3 4 |
glBegin( GL_QUADS ); glTexCoord2f( cx0, cy0 ); glVertex2f( 0.0f, 0.0f ); glTexCoord2f( cx1, cy0 ); glVertex2f( 1.0f, 0.0f ); //... |
Werbeanzeige