Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Jul 17, 2025 14:18

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Autor Nachricht
BeitragVerfasst: Sa Aug 25, 2007 19:12 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
I am stumped by my inability to code a simple threaded texture loader. I have coded a simple application to load 4 textures into an array of GLUInt and the OpenGL timer doing the drawing will either display a white box if there is no data there, or the four textures if they have been loaded.

With my application, I have two ways of loading the four textures - the first is a loop in the OnClick event of a TButton, the second is in the exact same code loop, but this time it is kicked off by a call to BeginThread. When I start the application, it will display four white boxes as no textures have been loaded. As soon as I press the "Load in OnClick" button the images are shown as the textures are loaded. If I press the "Load in BeginThread" button, either then or just after the application loads - then my textures disappear.

Does anyone know why the textures can't seem to be loaded inside a BeginThread? To explain myself better I have decided to attach a 55K .zip file with the program and textures I am trying to load in a thread - if anyone wanted to have a look at it, it should compile straight away.


Dateianhänge:
Dateikommentar: Source code and textures to test.
ThreadTextureLoader.zip [55.75 KiB]
342-mal heruntergeladen

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk
Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Aug 25, 2007 19:23 
Offline
DGL Member
Benutzeravatar

Registriert: Sa Dez 28, 2002 11:13
Beiträge: 2244
The OpenGL Context (RC) is only made current in the main thread. You should call wglMakeCurrent from the texture loader thread. As an alternative there is the extension ARB_pixel_buffer_object which allows asynchronous texture upload.


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Aug 25, 2007 20:33 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Thank you for the response. I wonder if you could guide me a bit further by elaborating as I currently do not realise how that is achieved.

Isn't my single global DC used for rendering? I'm not rendering inside my thread, just loading data from file into an array of GLUInt. I tried adding a call to wglMakeCurrent (DC,RC); at the start of the thread code but it changes nothing - disappointed it wasn't so simple. I had assumed, wrongly obviously, that I didn't need to do much more than that as, as stated above, I have only have one DC established throughout the run of the program.

Do I need a shared context?

What do I need to do to my program to get the textures loaded in the thread that is started from the button press?

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Aug 26, 2007 13:26 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
pixel_buffer_objects is an relative new extension but only newer cards and newer driver support it. That could be an problem in you media software,

Yes its could be possible if you create an second context. Bind this context to the loader thread and share this with the other context. But i think it would be easier to load only the images in the loader thread and create the textures in the renderthread. You only need to transfer some informations to the renderthread. Like pointer of the data, width, height and format. If you create the textures with glTexImage2D it only needs 1-2 ms to upload the data. That should be easy and fast enough.


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 4 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.011s | 17 Queries | GZIP : On ]