Click here to Skip to main content
15,898,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How can access the same port by diffreant threads at same time? Pin
Cedric Moonen14-Nov-10 21:59
Cedric Moonen14-Nov-10 21:59 
GeneralRe: How can access the same port by diffreant threads at same time? Pin
CPallini14-Nov-10 21:22
mveCPallini14-Nov-10 21:22 
Questionhow to display contents of a text file in EditBox?? [modified] Pin
MahaKh14-Nov-10 19:45
MahaKh14-Nov-10 19:45 
QuestionRe: how to display contents of a text file in EditBox?? Pin
CPallini14-Nov-10 21:28
mveCPallini14-Nov-10 21:28 
AnswerRe: how to display contents of a text file in EditBox?? Pin
Cool_Dev14-Nov-10 21:42
Cool_Dev14-Nov-10 21:42 
QuestionReadDirectoryChangesW failing Pin
Subrat Patnaik14-Nov-10 19:25
Subrat Patnaik14-Nov-10 19:25 
AnswerRe: ReadDirectoryChangesW failing Pin
Richard MacCutchan14-Nov-10 23:05
mveRichard MacCutchan14-Nov-10 23:05 
QuestionOpengl Multithreading (wglMakeCurrent() & wglShareLists() ) issue Pin
James_72214-Nov-10 18:32
James_72214-Nov-10 18:32 
I am trying to multi-thread my OpenGL code but I have been having trouble. At first, I thought that using opengl inside an alternate thread was impossible, so I just did loading operations and passed the data to opengl in the main thread (I knew once I started passing too much data the main thread would lockup, and noticeably freeze the execution of the program while the data was being moved). I found some forum threads discussing opengl and multi-threading but they don't discuss the details that I'm looking for. namely, how and where do I use wglMakeCurrent() and wglShareLists().

I have been trying to create a display list in the alternate thread with the instructions outlined in the aforementioned forum posts but it crashes every time. I can load the model data, I can even load shaders, but loading a model (of any size) crashes the program.

I will show some code snippets but there is really too much to put in one post:

//This is the code initializing the 2 Render Contexts
	if (!(app.hDC=GetDC(app.hWnd))                     || // Get A Device Context?
        !(PixelFormat=ChoosePixelFormat(app.hDC,&pfd)) || // Did Windows Find A Matching Pixel Format?
        !SetPixelFormat(app.hDC,PixelFormat,&pfd)      || // Able To Set The Pixel Format?
        !(app.hRC=wglCreateContext(app.hDC))           || // Able To Get A Rendering Context?
        !(app.hRC_thd=wglCreateContext(app.hDC))       || // Get the second context (for loading in parallel thread)
        !(wglShareLists(app.hRC, app.hRC_thd))         ||
        !wglMakeCurrent(app.hDC,app.hRC))		          // Try To Activate The Rendering Context
	{
		KillGLWindow();
		return false;
	}

This next bit is all the initialization and render using opengl
GLuint o;                                 // display list handle
vector<v3> v,n;                           // verts, norms
vector<v2> u;                             // texcoords (UVs)
vector<face> f;                           // polygons (faces)
bool done = false;
void load_thread(void* null)              // alternate thread entry point
{
    wglMakeCurrent(app.hDC, app.hRC_thd); // works fine (seemingly)
    load_rs_shdr();                       // works fine
    load_obj("cell.obj", v,n,u,f);        // works fine
    gen_display_list(o, v, n, u, f);      // crashes my program
    done = true;
    return;
}

bool init()
{
    init_med(v3(0,0,0));                    //function to initialize opengl (enable depth, lighting, etc...)
    set_light_const(v3(0,10,0), v3(1,1,1)); //enable a light
    _beginthread(load_thread, 0, (void*)0); //function declared in process.h
    return true;
}

bool render()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    gluLookAt(0,0,5,0,0,0,0,1,0);
    if(done)
        glCallList(o);

    return true;
}


I know for sure that my loading functions work, I've been using them for a while now inside my single threaded apps.

I appreciate any help or suggestions anyone has.
QuestionHow to get the whole view's screen shot when the view has scroll bar ? Pin
wangningyu14-Nov-10 17:34
wangningyu14-Nov-10 17:34 
AnswerRe: How to get the whole view's screen shot when the view has scroll bar ? Pin
Dr.Walt Fair, PE14-Nov-10 18:16
professionalDr.Walt Fair, PE14-Nov-10 18:16 
GeneralRe: How to get the whole view's screen shot when the view has scroll bar ? Pin
wangningyu14-Nov-10 18:49
wangningyu14-Nov-10 18:49 
GeneralRe: How to get the whole view's screen shot when the view has scroll bar ? Pin
Dr.Walt Fair, PE14-Nov-10 19:02
professionalDr.Walt Fair, PE14-Nov-10 19:02 
GeneralRe: How to get the whole view's screen shot when the view has scroll bar ? Pin
wangningyu14-Nov-10 19:06
wangningyu14-Nov-10 19:06 
AnswerRe: How to get the whole view's screen shot when the view has scroll bar ? Pin
Randor 14-Nov-10 19:25
professional Randor 14-Nov-10 19:25 
GeneralRe: How to get the whole view's screen shot when the view has scroll bar ? Pin
wangningyu14-Nov-10 19:27
wangningyu14-Nov-10 19:27 
QuestionHow can find List item click or checkbox click? Pin
Le@rner12-Nov-10 22:22
Le@rner12-Nov-10 22:22 
AnswerRe: How can find List item click or checkbox click? Pin
Richard MacCutchan12-Nov-10 23:36
mveRichard MacCutchan12-Nov-10 23:36 
GeneralRe: How can find List item click or checkbox click? Pin
Le@rner12-Nov-10 23:48
Le@rner12-Nov-10 23:48 
GeneralRe: How can find List item click or checkbox click? Pin
Richard MacCutchan13-Nov-10 0:18
mveRichard MacCutchan13-Nov-10 0:18 
AnswerRe: How can find List item click or checkbox click? Pin
Code-o-mat13-Nov-10 0:47
Code-o-mat13-Nov-10 0:47 
AnswerRe: How can find List item click or checkbox click? Pin
David Crow13-Nov-10 15:41
David Crow13-Nov-10 15:41 
GeneralRe: How can find List item click or checkbox click? Pin
«_Superman_»14-Nov-10 4:01
professional«_Superman_»14-Nov-10 4:01 
QuestionFault Address error Pin
MKC00212-Nov-10 21:24
MKC00212-Nov-10 21:24 
AnswerRe: Fault Address error Pin
Stephen Hewitt13-Nov-10 2:27
Stephen Hewitt13-Nov-10 2:27 
AnswerRe: Fault Address error Pin
Code-o-mat13-Nov-10 8:48
Code-o-mat13-Nov-10 8:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.