![]() |
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:
|
Re: OpenGl Rendercontex schützen
Liste der Anhänge anzeigen (Anzahl: 1)
Zitat:
wollte nur sagen das die Koordinaten sich in BassBoxInfo befinden und korrekt übergeben werden Zitat:
Kann man da was in
Delphi-Quellcode:
ändern damit das nicht passiert ?
gluPerspective(45, BassBoxInfo^.w / BassBoxInfo^.h, 1, 1000.0);
Zitat:
zeichnet immer neu gibt es da einen Lock befehl oder so der das verhindert ? gruss Emil |
Re: OpenGl Rendercontex schützen
Also als erstes zur falschen Position:
ich bin mir nicht sicher, aber kann es sein, dass glViewport(X, Y, W, H); Probleme macht? Probier mal glViewport(0, 0, W, H); aus. Ich weiß ja nicht, für was die Variablen X und Y genau sollen, ich denke, dass sie die Fensterposition beinhalten. Jedoch ist diese für OpenGL egal, da das komplett unterschiedliche Sachen sind. Zum Flackern: Das Flackern an sich sagt mir schon was, doch das kommt mir sehr seltsam vor. In OpenGl flackert normalerweise nichts, da du alles in einen Background-Buffer zeichnest, der dann in einem Rutsch ans Fenster übergeben wird - aber erst wenn er fertig ist. Ich glaub, dein Code hat da irgendwo ne Macke. PS: das Flackern kann auch passieren, wenn du OpenGl mit GDI-Objekten (z.B. der VCL) kombinierst. Da flackert aber nicht OpenGl sondern die VCL bzw. GDI-Sachen. |
Re: OpenGl Rendercontex schützen
Liste der Anhänge anzeigen (Anzahl: 1)
Ja sie werden kombiniert allerdings nur zum laden der Texturen (im Plugin)
Habe mal ein Sample angehängt da kannst sehen das es flackert starte dazu das Vulcan Plugin.. Das Plugin ist zwar eigentlich unnötig da nicht viel Visualisiert wird.. aber egal Den Berg kann man verschieben sowie andere objekte von verschiedenen Plugins Mit der Space taste werden die original positionen wieder hergestellt. Doppelklick ins panel = FullScreen with GenBitmap zeigt die Vis in einen eigenen Fenster da kannst du sehen das es probleme biem resitz gibt. Die Koordinaten x,y sind 0,0 gruss EMil EDIT: noch ein pic angehängt getestet mit XP denke das bei Vista probleme auftauchen könnten kann es nicht testen oder ändern habe kein Vista |
Re: OpenGl Rendercontex schützen
Liste der Anhänge anzeigen (Anzahl: 1)
habe leider ein etwa gleiches problem mit dem Font
habe es umgestellt funktioniert aber nicht da die Matrix zweimal geändert wird in der gleichen procedure.
Delphi-Quellcode:
procedure glPrintBitmap(x, y : GLFloat; text : pchar; fontset : GLint);
begin glPushAttrib(GL_ALL_ATTRIB_BITS); try if (fontset>1) then fontset :=1; glBindTexture(GL_TEXTURE_2D,fontset); // Select Our Font Texture glDisable(GL_DEPTH_TEST); // Disables Depth Testing // 1 mal geändert glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPushMatrix(); // Store The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(0,640,0,480,-100,100); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glPushMatrix(); // Store The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix glTranslated(x,y,0); // Position The Text (0,0 - Bottom Left) glListBase(base - 32 + (128 * cardinal(fontset))); // Choose The Font Set (0 or 1) glCallLists(strlen(text),GL_BYTE,text); // Write The Text To The Screen // 2 mal geändert glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glPopMatrix(); // Restore The Old Projection Matrix glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glPopMatrix(); // Restore The Old Projection Matrix glEnable(GL_DEPTH_TEST); // Enables Depth Testing finally glPopAttrib; end; end;
Delphi-Quellcode:
kannst mir nochmal nen tip geben wie ich das hin bekomme ?
procedure HoldMatrixFontMode(x, y : GLFloat; text : pchar; fontset : GLint);
var iMatrixMode : integer; begin glGetIntegerv(GL_MATRIX_MODE, @iMatrixMode); glMatrixMode(GL_PROJECTION); glPushMatrix; try glPrintBitmap(x, y, text, fontset); finally glMatrixMode(GL_PROJECTION); glPopMatrix; glMatrixMode(iMatrixMode); end; end; Aufruf..
Delphi-Quellcode:
EDIT:
HoldMatrixFontMode(10, 13, SongName, 1);
Von Text kann man da nicht sprechen.. Hat sich erledigt ... gruss Emil |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:59 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