![]() |
OpenGl Rendercontex schützen
Liste der Anhänge anzeigen (Anzahl: 1)
Ich setze auf einen OpenGl Rendercontex eine Progressbar auf
Leider zerstört meine function die Zorder der Plugins und verändert auch diverse andere Dinge Gibt es eine möglichkeit die vom Plugin zu schützen wenn ich meine drüber setze ?
Delphi-Quellcode:
gruss Emil
procedure DrawPosition;
Var x1,x2, x12,x21, z1,y1, y2,x,y,hd : GLfloat; d1,d2 : GLfloat; overdraw : GLfloat; begin glMatrixMode(GL_PROJECTION); //--> zerstört die z order glLoadIdentity; gluPerspective(45, BassBoxInfo^.w / BassBoxInfo^.h, 1, 1000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity; d1 := 0.05; d2 := 0.01; overdraw := 0.03; glDepthMask(ByteBool(GL_FALSE)); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glBindTexture(GL_TEXTURE_2D, BarTexture); glColor4f( 1.0, 1.0, 1.0, 0.0); z1 := -4.0; y1 := -1.65; y2 := y1 + d1 - d2 + overdraw; x1 := -2.21; x2 := 2.20; x12 := x1 + (d1 - d2) * 0.3; x21 := x2 - (d1 - d2) * 0.3; glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(x1, y2, z1); glTexCoord2f(1.0, 0.0); glVertex3f(x1, y1, z1); glTexCoord2f(1.0, 0.3); glVertex3f(x12, y1, z1); glTexCoord2f(0.0, 0.3); glVertex3f(x12, y2, z1); glTexCoord2f(0.0, 0.3); glVertex3f(x12, y2, z1); glTexCoord2f(1.0, 0.3); glVertex3f(x12, y1, z1); glTexCoord2f(1.0, 0.7); glVertex3f(x21, y1, z1); glTexCoord2f(0.0, 0.7); glVertex3f(x21, y2, z1); glTexCoord2f(0.0, 0.7); glVertex3f(x21, y2, z1); glTexCoord2f(1.0, 0.7); glVertex3f(x21, y1, z1); glTexCoord2f(1.0, 1.0); glVertex3f(x2, y1, z1); glTexCoord2f(0.0, 1.0); glVertex3f(x2, y2, z1); glEnd(); glBindTexture(GL_TEXTURE_2D, PeaksTexture); hd :=(d1 - d2) * 4.0; x :=(x2 - x1) * CurrentPositionPart + x1; y :=(y2 + y1) * 0.5; glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(x - hd, y - hd, z1); glTexCoord2f(0.0, 1.0); glVertex3f(x - hd, y + hd, z1); glTexCoord2f(1.0, 1.0); glVertex3f(x + hd, y + hd, z1); glTexCoord2f(1.0, 0.0); glVertex3f(x + hd, y - hd, z1); glEnd(); glDepthMask(ByteBool(GL_TRUE)); // glDisable(GL_BLEND); --> zerstört das GL_Blend vom Plugin end; |
Re: OpenGl Rendercontex schützen
Anscheindend setzt du ein Attribut, was später nicht mehr zurückgesetzt wird. Du kannst die Attribute zwischenspeichern und später wieder zurücksetzen. Versuchs mal mit diesem Code:
Delphi-Quellcode:
Das gleiche gibts auch für Matrizen: glPushMatrix und glPopMatrix
glPushAttrib(GL_ALL_ATTRIB_BITS);
try // Render Code finally glPopAttrib; end; Bei den Matrizen wird nur die aktuell benutze Matrix gespeichert. Von daher würde ein Beispiel-Code so aussehen:
Delphi-Quellcode:
(ungetestet, da Delphi im Moment nicht offen)
var iMatrixMode : integer;
begin glGetIntegerv(GL_MATRIX_MODE, @i); glMatrixMode(GL_PROJECTION); glPushMatrix; try // Render Code finally glMatrixMode(GL_PROJECTION); glPopMatrix; glMatrixMode(iMatrixMode); end; end; |
Re: OpenGl Rendercontex schützen
Danke
Werde mal schaun ob ich damit zurecht komme. EDIT: Damit komme ich zurecht da die Matrix nur einmal verwendet wird
Delphi-Quellcode:
Hier habe ich ein Problem
procedure HoldMatrixMode;
var iMatrixMode : integer; begin glGetIntegerv(GL_MATRIX_MODE, @iMatrixMode); glMatrixMode(GL_PROJECTION); glPushMatrix; try DrawPosition; finally glMatrixMode(GL_PROJECTION); glPopMatrix; glMatrixMode(iMatrixMode); end; end;
Delphi-Quellcode:
weiss nicht wo ich ansetzen soll da mehrere Attribute verändert werden
glPushAttrib(GL_ALL_ATTRIB_BITS);
try // Render Code finally glPopAttrib; end; innerhalb der Drawposition meinst du das so ?
Delphi-Quellcode:
wie sieht das mit
glPushAttrib(GL_ALL_ATTRIB_BITS);
try // RenderCode glDepthMask(ByteBool(GL_FALSE)); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); finally glPopAttrib; end;
Delphi-Quellcode:
aus?
glBindTexture(GL_TEXTURE_2D, BarTexture);
gruss Emil |
Re: OpenGl Rendercontex schützen
Zitat:
Zitat:
|
Re: OpenGl Rendercontex schützen
Zitat:
Was Rendern `? (keine dumme frage) Ich befinde mich innerhalb DrawPosition kann ja nun nicht wieder DrawPosition innerhalb Drawposition aufrufen. wäre eine endlose sache. zur veranschaulichung
Delphi-Quellcode:
EDIT:
procedure DrawPosition;
Var x1,x2, x12,x21, z1,y1, y2,x,y,hd : GLfloat; d1,d2 : GLfloat; overdraw : GLfloat; begin glMatrixMode(GL_PROJECTION); glLoadIdentity; gluPerspective(45, BassBoxInfo^.w / BassBoxInfo^.h, 1, 1000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity; d1 := 0.05; d2 := 0.01; overdraw := 0.03; // PushAttrib glPushAttrib(GL_ALL_ATTRIB_BITS); try // RenderCode glDepthMask(ByteBool(GL_FALSE)); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); finally glPopAttrib; end; glBindTexture(GL_TEXTURE_2D, BarTexture); glColor4f( 1.0, 1.0, 1.0, 0.0); z1 := -4.0; y1 := -1.65; y2 := y1 + d1 - d2 + overdraw; x1 := -2.21; x2 := 2.20; x12 := x1 + (d1 - d2) * 0.3; x21 := x2 - (d1 - d2) * 0.3; glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(x1, y2, z1); glTexCoord2f(1.0, 0.0); glVertex3f(x1, y1, z1); glTexCoord2f(1.0, 0.3); glVertex3f(x12, y1, z1); glTexCoord2f(0.0, 0.3); glVertex3f(x12, y2, z1); glTexCoord2f(0.0, 0.3); glVertex3f(x12, y2, z1); glTexCoord2f(1.0, 0.3); glVertex3f(x12, y1, z1); glTexCoord2f(1.0, 0.7); glVertex3f(x21, y1, z1); glTexCoord2f(0.0, 0.7); glVertex3f(x21, y2, z1); glTexCoord2f(0.0, 0.7); glVertex3f(x21, y2, z1); glTexCoord2f(1.0, 0.7); glVertex3f(x21, y1, z1); glTexCoord2f(1.0, 1.0); glVertex3f(x2, y1, z1); glTexCoord2f(0.0, 1.0); glVertex3f(x2, y2, z1); glEnd(); glBindTexture(GL_TEXTURE_2D, PeaksTexture); hd :=(d1 - d2) * 4.0; x :=(x2 - x1) * CurrentPositionPart + x1; y :=(y2 + y1) * 0.5; glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(x - hd, y - hd, z1); glTexCoord2f(0.0, 1.0); glVertex3f(x - hd, y + hd, z1); glTexCoord2f(1.0, 1.0); glVertex3f(x + hd, y + hd, z1); glTexCoord2f(1.0, 0.0); glVertex3f(x + hd, y - hd, z1); glEnd(); // PushAttrib glPushAttrib(GL_ALL_ATTRIB_BITS); try glDepthMask(ByteBool(GL_TRUE)); glDisable(GL_BLEND); finally glPopAttrib; end; end; Bei Plugins ohne Texturen wird bei mir die Texture für die Bar nicht angezeigt! Hmmmm Ach so der aufruf der RenderFunktion
Delphi-Quellcode:
gruss Emil
procedure ProgressBarRender;
begin if (PosCounter = 0) then begin CurrentLength := BassBoxInfo.MediaLength; if (CurrentLength = 0) then CurrentLength := 1; CurrentPosition := Round(1000 * Bass_ChannelBytes2Seconds(BB_VisDataThread.Stream, Bass_ChannelGetPosition(BB_VisDataThread.Stream, BASS_POS_BYTE))); If not (PlayState = 0) and not (CurrentPosition = -1)Then begin CurrentPositionPart := (CurrentPosition / 1000) / CurrentLength; if (CurrentPositionPart > 1) then CurrentPositionPart := 1; end else CurrentPositionPart := 0; end; PosCounter := (PosCounter +1) and 3; HoldMatrixMode; end; |
Re: OpenGl Rendercontex schützen
Delphi-Quellcode:
procedure DrawPosition;
Var x1,x2, x12,x21, z1,y1, y2,x,y,hd : GLfloat; d1,d2 : GLfloat; overdraw : GLfloat; begin glMatrixMode(GL_PROJECTION); glLoadIdentity; gluPerspective(45, BassBoxInfo^.w / BassBoxInfo^.h, 1, 1000.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity; d1 := 0.05; d2 := 0.01; overdraw := 0.03; // PushAttrib glPushAttrib(GL_ALL_ATTRIB_BITS); try // RenderCode glDepthMask(ByteBool(GL_FALSE)); glDisable(GL_LIGHTING); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); // <---------- FINALLY WEG GEMACHT // Rendern glBindTexture(GL_TEXTURE_2D, BarTexture); glColor4f( 1.0, 1.0, 1.0, 0.0); z1 := -4.0; y1 := -1.65; y2 := y1 + d1 - d2 + overdraw; x1 := -2.21; x2 := 2.20; x12 := x1 + (d1 - d2) * 0.3; x21 := x2 - (d1 - d2) * 0.3; glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(x1, y2, z1); glTexCoord2f(1.0, 0.0); glVertex3f(x1, y1, z1); glTexCoord2f(1.0, 0.3); glVertex3f(x12, y1, z1); glTexCoord2f(0.0, 0.3); glVertex3f(x12, y2, z1); glTexCoord2f(0.0, 0.3); glVertex3f(x12, y2, z1); glTexCoord2f(1.0, 0.3); glVertex3f(x12, y1, z1); glTexCoord2f(1.0, 0.7); glVertex3f(x21, y1, z1); glTexCoord2f(0.0, 0.7); glVertex3f(x21, y2, z1); glTexCoord2f(0.0, 0.7); glVertex3f(x21, y2, z1); glTexCoord2f(1.0, 0.7); glVertex3f(x21, y1, z1); glTexCoord2f(1.0, 1.0); glVertex3f(x2, y1, z1); glTexCoord2f(0.0, 1.0); glVertex3f(x2, y2, z1); glEnd(); glBindTexture(GL_TEXTURE_2D, PeaksTexture); hd :=(d1 - d2) * 4.0; x :=(x2 - x1) * CurrentPositionPart + x1; y :=(y2 + y1) * 0.5; glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(x - hd, y - hd, z1); glTexCoord2f(0.0, 1.0); glVertex3f(x - hd, y + hd, z1); glTexCoord2f(1.0, 1.0); glVertex3f(x + hd, y + hd, z1); glTexCoord2f(1.0, 0.0); glVertex3f(x + hd, y - hd, z1); glEnd(); // <--------- TRY - BLOCK WEG GEMACHT finally glPopAttrib; end; end; |
Re: OpenGl Rendercontex schützen
Liste der Anhänge anzeigen (Anzahl: 1)
Danke ;)
Bei mir ging ein licht auf und habe es genauso geändert wie du es mir gezeigt hast. JEtzt habe ich nur noch ein Problem mit den Texturen .. Hier mal der Code von einer der Plugins was es beim Rendern macht. Komme nicht dahinter warum mir die Texture nicht angezeigt wird. Es geht nur um den OpenGl Kram das andere kannst du ignorieren ;)
Delphi-Quellcode:
gruss Emil
CASE %BBP_RENDER
'// Draw the scene using BBP.LeftPeak and BBP.RightPeak LOCAL nLValue, nRValue, RGBColor AS LONG LOCAL pulse AS DOUBLE, R1, G1, B1, R2, G2, B2 AS BYTE nLValue = (BBP.Lpeak / 700) nRValue = (BBP.Rpeak / 768) rXangle = rXangle + 0.3 '// grDXangle rYangle = rYangle + 0.5 '// grDYangle rZangle = rZangle + 0.7 '// grDZangle pulse = Max(nLValue, nRValue) / 7 '// Pulsating section CALL glMatrixMode(%GL_PROJECTION) Call glLoadIdentity Call gluPerspective(35# - pulse, 1.25, 0.1, 150#) CALL glMatrixMode(%GL_MODELVIEW) '// Velocity section pulse = Abs(pulse / 4) rXangle = rXangle + pulse '// grDXangle rYangle = rYangle + pulse '// grDYangle rZangle = rZangle + pulse '// grDZangle '// Very important we must reassign BBP.RC to the new BBP.DC '// Note: don't use permanent DC, this produce better and smoother display Call wglMakeCurrent(BBP.DC, BBP.rc) CALL glClear(%GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT) Call glLoadIdentity Call gluLookAt(0#, 0#, 5#, 0#, 0#, 0#, 0#, 1#, 0#) Call glRotated(rXangle, 1#, 0#, 0#) Call glRotated(rYangle, 0#, 1#, 0#) Call glRotated(rZangle, 0#, 0#, 1#) '// Draw Diamond RGBColor = LevelColr(nLValue) R2 = BBP_GetRValue(RGBColor) G2 = BBP_GetGValue(RGBColor) B2 = BBP_GetBValue(RGBColor) RGBColor = LevelColr(nRValue) R1 = BBP_GetRValue(RGBColor) G1 = BBP_GetGValue(RGBColor) B1 = BBP_GetBValue(RGBColor) '// Up CALL glBegin(%GL_TRIANGLE_FAN) Call glColor3ub(R2, G2, B2): Call glVertex3d(0#, 1.414, 0#) Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#) Call glColor3ub(0, 0, 0): Call glVertex3d(1#, 0#, -1#) Call glColor3ub(R1, G1, B1): Call glVertex3d(-1#, 0#, -1#) Call glColor3ub(0, 0, 0): Call glVertex3d(-1#, 0#, 1#) Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#) Call glEnd '// Down CALL glBegin( %GL_TRIANGLE_FAN) Call glColor3ub(R2, G2, B2): Call glVertex3d(0#, -1.414, 0#) Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#) Call glColor3ub(64, 64, 64): Call glVertex3d(-1#, 0#, 1#) Call glColor3ub(R1, G1, B1): Call glVertex3d(-1#, 0#, -1#) Call glColor3ub(64, 64, 64): Call glVertex3d(1#, 0#, -1#) Call glColor3ub(R1, G1, B1): Call glVertex3d(1#, 0#, 1#) Call glEnd |
Re: OpenGl Rendercontex schützen
Das hat mehrere Gründe glaub ich:
|
Re: OpenGl Rendercontex schützen
Zitat:
Delphi-Quellcode:
das fehlt
// <---------- FINALLY WEG GEMACHT
// Rendern glBindTexture(GL_TEXTURE_2D, BarTexture); glColor4f( 1.0, 1.0, 1.0, 0.0);
Delphi-Quellcode:
Das Plugin selbst übergibt keine Texture das macht meine Render Funktion
glEnable(GL_TEXTURE_2D)
Nehme an es liegt an der fehlenden glEnable(GL_TEXTURE_2D) werd es testen .. EDIT: Das funktioniert jetzt ;) Nur noch zwei kleine probleme Die Bar setzt sich nicht immer hundert prozent an das OpenGl Window.
Delphi-Quellcode:
befinden sich in BassBoxInfo^.
procedure ResizeGLwindow(handle : HWND; X, Y, W, H: Integer);
begin SetWindowPos(handle, 0, 0, 0, W, H, SWP_NOZORDER); glViewport(X, Y, W, H); BassBoxInfo^.Msg := BBP_SIZE; BassBoxInfo^.ParentWindow := Handle; BbpPluginFunc(BassBoxInfo^); BassBoxInfo^.x := X; BassBoxInfo^.y := Y; BassBoxInfo^.w := W; BassBoxInfo^.h := H; end; Das andere Problem die Bar Flacker bei den Plugins welche keine Texture haben Wie kann man das verhindern ? Gruss Emil |
Re: OpenGl Rendercontex schützen
Zitat:
Zitat:
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:15 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz