C programming

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
Just some more perk for you to keep trying.
5x0ftf.png
 

bhtan760

Banned
Joined
Aug 11, 2013
Messages
249
Reaction score
0
What is the most common reason for windows freezings?

I am trying to render the program..
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
What is the most common reason for windows freezings?

I am trying to render the program..

Define windows freezing. Your application window freeze or the whole Windows OS freeze ?
If you observe high CPU, then it's probably an infinite loop somewhere.

The GLUT also have it's own set of loop for capturing windows event. It's in the same main thread as the rest of the code running. Like I said, it's an event driven application like all Windows GUI application. If you have an intensive job, use a separate thread to do it.

Add On:

BTW what is the objective of your work ? Is it assignments that has to be completed in C, FYP or any such academic assignments ?

It seems to be you have a rather lacking knowledge with development in C. If it's just OpenGL, perhaps you will feel more comfortable using JOGL, so that you can better focus on the problem at hand rather than struggling over how to develop properly in C ?
 
Last edited:

bhtan760

Banned
Joined
Aug 11, 2013
Messages
249
Reaction score
0
Define windows freezing. Your application window freeze or the whole Windows OS freeze ?
If you observe high CPU, then it's probably an infinite loop somewhere.

The GLUT also have it's own set of loop for capturing windows event. It's in the same main thread as the rest of the code running. Like I said, it's an event driven application like all Windows GUI application. If you have an intensive job, use a separate thread to do it.

Add On:

BTW what is the objective of your work ? Is it assignments that has to be completed in C, FYP or any such academic assignments ?

It seems to be you have a rather lacking knowledge with development in C. If it's just OpenGL, perhaps you will feel more comfortable using JOGL, so that you can better focus on the problem at hand rather than struggling over how to develop properly in C ?

i need to finish in C,must be opengl.

the application window freezes

the assignment is a meshviewer
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
i need to finish in C,must be opengl.

the application window freezes

the assignment is a meshviewer

Okay, did you observe a high cpu of near 100% when your application window freezes ? If not, it might not be freezer, but rather not responding or perhaps it could be your codes are not performing anything for the screen to change.
 

bhtan760

Banned
Joined
Aug 11, 2013
Messages
249
Reaction score
0
Okay, did you observe a high cpu of near 100% when your application window freezes ? If not, it might not be freezer, but rather not responding or perhaps it could be your codes are not performing anything for the screen to change.

i am on my way to debug,it has another instance,close the program,

the rendering is about to work,

however,it appears that it is still reading the verticies and halfway through it already display?false alarm?

what i mean is: displaymodel is still looping then i already go into main loopalready?

// register your callback functions
glutDisplayFunc(displayModel);

// enter the main loop
glutMainLoop();
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
i am on my way to debug,it has another instance,close the program,

the rendering is about to work,

however,it appears that it is still reading the verticies and halfway through it already display?false alarm?

I don't know how you are reading your model data. You should read first before you display ?
 

bhtan760

Banned
Joined
Aug 11, 2013
Messages
249
Reaction score
0
i found out there is a data model with

Vertex 1 -27.6745 -150.363 -22.3534
Vertex 2 26.7081 -199.014 18.9987
Vertex 3 40.7951 -200.1 18.5202
Vertex 4 -5.85215 -148.649 32.2993
Vertex 5 -62.7425 -115.67 0.0102861
Vertex 6 -34.8256 -24.1991 -24.3786
Vertex 7 7.72046 7.05242 -16.6106
Vertex 8 19.9969 -100.416 -60.7215
Vertex 9 63.5247 -126.864 -26.3147


greater than >1,what should I do?

there is another file with:
Vertex 1 40.9791 189.743 -727.882
Vertex 2 41.4823 188.372 -726.062
Vertex 3 40.7936 187.195 -727.055
Vertex 4 41.9104 189.779 -725.824
Vertex 5 40.5246 185.65 -727.031

my vertex file with 0<x<1 manage to display at the very least
 
Last edited:

stupidbodo

Junior Member
Joined
Mar 26, 2010
Messages
89
Reaction score
0
hi bhtan, I recommend you to make it easy for others to see
your snippet by using code tag. This will stretch you anywhere you go and is
programming universal :s13: .

Instead of blatantly paste your snippet you make a quote around it so that it is easier to see your code.

Code:
Vertex 1 -27.6745 -150.363 -22.3534
Vertex 2 26.7081 -199.014 18.9987
Vertex 3 40.7951 -200.1 18.5202
Vertex 4 -5.85215 -148.649 32.2993
Vertex 5 -62.7425 -115.67 0.0102861
Vertex 6 -34.8256 -24.1991 -24.3786
Vertex 7 7.72046 7.05242 -16.6106
Vertex 8 19.9969 -100.416 -60.7215
Vertex 9 63.5247 -126.864 -26.3147


there is another file with:
Vertex 1 40.9791 189.743 -727.882
Vertex 2 41.4823 188.372 -726.062
Vertex 3 40.7936 187.195 -727.055
Vertex 4 41.9104 189.779 -725.824
Vertex 5 40.5246 185.65 -727.031
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
i found out there is a data model with

Vertex 1 -27.6745 -150.363 -22.3534
Vertex 2 26.7081 -199.014 18.9987
Vertex 3 40.7951 -200.1 18.5202
Vertex 4 -5.85215 -148.649 32.2993
Vertex 5 -62.7425 -115.67 0.0102861
Vertex 6 -34.8256 -24.1991 -24.3786
Vertex 7 7.72046 7.05242 -16.6106
Vertex 8 19.9969 -100.416 -60.7215
Vertex 9 63.5247 -126.864 -26.3147


greater than >1,what should I do?

there is another file with:
Vertex 1 40.9791 189.743 -727.882
Vertex 2 41.4823 188.372 -726.062
Vertex 3 40.7936 187.195 -727.055
Vertex 4 41.9104 189.779 -725.824
Vertex 5 40.5246 185.65 -727.031

my vertex file with 0<x<1 manage to display at the very least

Scaling ? You can either scale inside OpenGL using glScalef function, or you can always scale it yourself.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
could it be because it is it is in the mainloop that is why loop all the time/

Don't get you. Are you saying that you can codes that run in the main thread of the process after invoking then "glutmainloop" function ?

You can't do that, because "glutmainloop" function is helping you by managing the windows events. It will only return from the "glutmainloop" function when you end the opengl program. You should do whatever you need to do before the "glutmainloop" invocation.

If you are building a meshviewer that will still enable you to load a new mesh after the program has been loaded, it has to be done via events handling concept.

For eg: create menu where you can choose and a file chooser dialog box opens and then you choose the new mesh to open.
 

bhtan760

Banned
Joined
Aug 11, 2013
Messages
249
Reaction score
0
Don't get you. Are you saying that you can codes that run in the main thread of the process after invoking then "glutmainloop" function ?

You can't do that, because "glutmainloop" function is helping you by managing the windows events. It will only return from the "glutmainloop" function when you end the opengl program. You should do whatever you need to do before the "glutmainloop" invocation.

If you are building a meshviewer that will still enable you to load a new mesh after the program has been loaded, it has to be done via events handling concept.

For eg: create menu where you can choose and a file chooser dialog box opens and then you choose the new mesh to open.

yes,i need a filechooser.
 

Asphodeli

Arch-Supremacy Member
Joined
Jul 8, 2001
Messages
23,277
Reaction score
4,255
#1 load mesh data from file and store in data struct. do this outside the opengl render loop. do not render if file is not loaded.
#2 once loaded, use glVertex and glMesh (triangle strip? quads? been a while since i touched it) to render on-screen.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
you mean i have to perform glScalef?

Why not ? If the scale of the mesh is larger than what your camera's FOV (or more precisely your view frustum) can accommodate, you either scale down the model or you widen your FOV. The effect is not all the same since large FOV introduce perspective distortion while scaling down your model is a linear function.
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,549
Reaction score
1,302
yes,i need a filechooser.

OpenGL itself has nothing to do with the windowing environment. GLUT doesn't offer such feature too. So if you want a filechooser, you need to either use the native Windows API (on windows), or if you want something more portable, you need to use a portable Windowing Toolkit.

This will be extra complication to your objective, is this really necessary ? You can always start up your application with the filename of your model specified you know ?

The simpler way is not to be portable, just stick with Win32 API calling GetOpenFileName. Dealing with Win32 is not going to be trivial, so have a deeper thought where is your focus in this project.
 

bhtan760

Banned
Joined
Aug 11, 2013
Messages
249
Reaction score
0
Why not ? If the scale of the mesh is larger than what your camera's FOV (or more precisely your view frustum) can accommodate, you either scale down the model or you widen your FOV. The effect is not all the same since large FOV introduce perspective distortion while scaling down your model is a linear function.

could it be too difficult for my opengl window to handle?

or is it because the numbers are too large that is why cannot load further
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top