• Advertisement
Sign in to follow this  

OpenGL .X Files In Opengl

This topic is 3671 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Has anyone converted the code from this Articles Code to C# or Vb.Net 0r some language that is easier to understand then Dev C Plus Plus Or has any found a way to use .x files in Opengl without Dx. I don't want to use any third party controls or dlls. Thanks Steve

Share this post


Link to post
Share on other sites
Advertisement
Well, to give you a general sense of what you'll need to do:

(1) Learn about all the aspects of an .x file.
(2) Learn how it's set up
(3) Write an importer for it using GL primitives.

Ta da!

Search around using google, I'm sure there are some similar experiences. And seeing if there's any source code for OGL .x importers already that you can look at would help too.

FlyingIsFun1217

Share this post


Link to post
Share on other sites
(1)No Kidding
(2)No Kidding
(3)No kidding

Ta Da!

Been there done that

If anybody has an answer for the question
that I posted.

Thanks
Steve

Share this post


Link to post
Share on other sites
If you've already studied the format it should be quite trivial to create a parser for it. Maybe google some tutorials on parsing text files.

Is it the parsing of the data which is giving you the problem, or is it a rendering problem. I've written code in c++ for openGL as well as for c# for directx( I wanted to load the data into my own formats rather then use the directx ones ).

Just let us know exactly what part of it you're getting caught up on and we can probably provide more help.

Share this post


Link to post
Share on other sites
I wanted to know if anyone converted
the code in that article so I didn't have
to do it if it was already done.

I don't want to convert because it will be
a handful of trouble.

I will find a lot of non equals between the
languages which will be a problem.

I have a lot of x files and I want to use them
in my gl app.

I haven't done any file parsing so it won't be
easy to do.

I have some vb not vb.net code of some of not all
of the .x file format being parsed.

It is going to be a big job to get it right.

If you know how to parse an x file and use it
with vb.net that would be cool.

Thanks
Steve

Share this post


Link to post
Share on other sites
Quote:
Original post by Steve5050
I don't want to convert because it will be
a handful of trouble.


In that case, you have bigger problems than 3d loaders.

FlyingIsFun1217

Share this post


Link to post
Share on other sites
Really,
Do you care to elaborate ol' wise one.

How do you know what problems I'm going to have?

Are you Psychic?

Share this post


Link to post
Share on other sites
While he's being a little blunt, I believe his point is that if you don't want to take the time to learn how to parse an ascii file then you're probably going to run into some much bigger road blocks down the road.

Maybe you should take a step back from trying to learn OpenGL for now and try writing some text based games to help build up your programming skills. If you don't want to delve deeper into parsing a 3d data file, why not try something easier to get your feet wet. I would recommend creating an ini file with key-value pairs in it and try parsing that. It will be useful to have down the road and will give you an initial feel for how to parse data

Share this post


Link to post
Share on other sites
I don't need to step back from anything.

All I asked was If anybody converted that
code from the article.

I don't need Ta Da!s

I started my own xfile loader yesterday, it
will be done.

I don't back down from a good challenge.

I was just lookin for another way.
If someone had shown me a way to write
a xfile loader, what would be so wrong with
that.

I could still learn from that,right?

Steve

Share this post


Link to post
Share on other sites
Hmmm not really, you can't generally learn by just looking at someone else's code. You need to understand the techniques behind it and how things work before you can actually learn something. I mean you could probably come away from it knowing how it works but you can't really learn the principles behind it.
I should point out though that you say "if someone had shown me a way to write
a xfile loader, what would be so wrong with that." but that article you posted at the beginning does show you how to write an xfile loader. What you're really looking for is someone to write a visual basic .net loader for you, in the end though I don't think you would actually come away with anything from that.

Share this post


Link to post
Share on other sites
Yeah, I was just pointing out that you need to know what to do before you do it.

That was my biggest problem (and still is, to a small degree), thinking that I could copy, mix, and match code, and understand it too.

Later on, when I started game development, I realized I was only fooling myself. And because of that, I am still learning when I could be farther ahead than I am.

Hopefully you'll learn something out of it, whether or not you struggle.

FlyingIsFun1217

Share this post


Link to post
Share on other sites
I actually started out using directx more than
a few years ago, I didn't like it and also when
I ran an app, there was always 100% cpu usage.

So I have dealt with x files before.

I understand the meshes,templates,materials and all
that stuff.

I had a 3d modeler application that was exporting xfiles
with extra commas that wouldn't work in my application, I wrote
a line by line app to knock off the commas. I worked that out on my
own.

I've used other engines Irrlict I used that and it was buggy and
100% cpu.

I bought Torgue years ago and that was a total waste.

So now I'm using opengl and it's going good,low cpu usage which
is good,all kinds of good things.

I don't need someone to give me vb.net code.

I'll make the loader and I'll have it working shortly.

Steve

Share this post


Link to post
Share on other sites
How are you using openGL and not getting 100% cpu, you must be using some kind of threading library. The reason you get 100% cpu is because you don't have some kind of sleep call in your code.
You shouldn't call another engine buggy just because you didn't know how to use it. It always bothers me when programmers say something is buggy because they refuse to give the time to learning it. How was torque a waste of time? Did you just not understand how to use it?
Knocking out a couple comma's is not parsing a file. You really really need to take a step back and go back to learning how the language actually works.
I would recommend you take a step back, try making something much simpler, maybe text based black jack, or a text based adventure game.
If you really don't want to learn programming, maybe take a look at the game maker's which are available out there.

Share this post


Link to post
Share on other sites
Steve5050:

1) Please stop hitting enter after every couple of words you type. This makes your posts very painful to read.

2) 100% CPU usage has absolutely nothing to do with the rendering API you use. It has to do with the way you interact with the Windows process scheduler. If you correctly process the Windows message queue with blocking wait calls or appropriately placed sleeps, you will not get constant 100% usage on either D3D or OpenGL.

3) 100% CPU usage is actually a good thing for CPU intensive applications that aren't user input event driven, such as games.

As others have suggested, you're trying to do something way over your head. Try to go a step backwards, and learn about the basics first. Writing a parser for an X file is a good learning step, and not very difficult to do.

Oh, and the article is not written in "Dev C Plus Plus", but in C++. DevC++ is an integrated development environment. C++ is the language.

Share this post


Link to post
Share on other sites
Quote:
Original post by Steve5050
I've used other engines Irrlict I used that and it was buggy and
100% cpu.


It is not because of Irrlict that CPU usage goes to 100%. It is because you are running an infinite loop, very much like the rest of the world does when they are doing a game.
The other option is to make your program input driver, like 3d Studio max, Blender, Maya, ...

Share this post


Link to post
Share on other sites
Quote:
Original post by Steve5050
I'll make the loader and I'll have it working shortly.


More power to ya bro. I'm not the one who needs the loader.

FlyingIsFun1217

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By LifeArtist
      Good Evening,
      I want to make a 2D game which involves displaying some debug information. Especially for collision, enemy sights and so on ...
      First of I was thinking about all those shapes which I need will need for debugging purposes: circles, rectangles, lines, polygons.
      I am really stucked right now because of the fundamental question:
      Where do I store my vertices positions for each line (object)? Currently I am not using a model matrix because I am using orthographic projection and set the final position within the VBO. That means that if I add a new line I would have to expand the "points" array and re-upload (recall glBufferData) it every time. The other method would be to use a model matrix and a fixed vbo for a line but it would be also messy to exactly create a line from (0,0) to (100,20) calculating the rotation and scale to make it fit.
      If I proceed with option 1 "updating the array each frame" I was thinking of having 4 draw calls every frame for the lines vao, polygons vao and so on. 
      In addition to that I am planning to use some sort of ECS based architecture. So the other question would be:
      Should I treat those debug objects as entities/components?
      For me it would make sense to treat them as entities but that's creates a new issue with the previous array approach because it would have for example a transform and render component. A special render component for debug objects (no texture etc) ... For me the transform component is also just a matrix but how would I then define a line?
      Treating them as components would'nt be a good idea in my eyes because then I would always need an entity. Well entity is just an id !? So maybe its a component?
      Regards,
      LifeArtist
    • By QQemka
      Hello. I am coding a small thingy in my spare time. All i want to achieve is to load a heightmap (as the lowest possible walking terrain), some static meshes (elements of the environment) and a dynamic character (meaning i can move, collide with heightmap/static meshes and hold a varying item in a hand ). Got a bunch of questions, or rather problems i can't find solution to myself. Nearly all are deal with graphics/gpu, not the coding part. My c++ is on high enough level.
      Let's go:
      Heightmap - i obviously want it to be textured, size is hardcoded to 256x256 squares. I can't have one huge texture stretched over entire terrain cause every pixel would be enormous. Thats why i decided to use 2 specified textures. First will be a tileset consisting of 16 square tiles (u v range from 0 to 0.25 for first tile and so on) and second a 256x256 buffer with 0-15 value representing index of the tile from tileset for every heigtmap square. Problem is, how do i blend the edges nicely and make some computationally cheap changes so its not obvious there are only 16 tiles? Is it possible to generate such terrain with some existing program?
      Collisions - i want to use bounding sphere and aabb. But should i store them for a model or entity instance? Meaning i have 20 same trees spawned using the same tree model, but every entity got its own transformation (position, scale etc). Storing collision component per instance grats faster access + is precalculated and transformed (takes additional memory, but who cares?), so i stick with this, right? What should i do if object is dynamically rotated? The aabb is no longer aligned and calculating per vertex min/max everytime object rotates/scales is pretty expensive, right?
      Drawing aabb - problem similar to above (storing aabb data per instance or model). This time in my opinion per model is enough since every instance also does not have own vertex buffer but uses the shared one (so 20 trees share reference to one tree model). So rendering aabb is about taking the model's aabb, transforming with instance matrix and voila. What about aabb vertex buffer (this is more of a cosmetic question, just curious, bumped onto it in time of writing this). Is it better to make it as 8 points and index buffer (12 lines), or only 2 vertices with min/max x/y/z and having the shaders dynamically generate 6 other vertices and draw the box? Or maybe there should be just ONE 1x1x1 cube box template moved/scaled per entity?
      What if one model got a diffuse texture and a normal map, and other has only diffuse? Should i pass some bool flag to shader with that info, or just assume that my game supports only diffuse maps without fancy stuff?
      There were several more but i forgot/solved them at time of writing
      Thanks in advance
    • By RenanRR
      Hi All,
      I'm reading the tutorials from learnOpengl site (nice site) and I'm having a question on the camera (https://learnopengl.com/Getting-started/Camera).
      I always saw the camera being manipulated with the lookat, but in tutorial I saw the camera being changed through the MVP arrays, which do not seem to be camera, but rather the scene that changes:
      Vertex Shader:
      #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; out vec2 TexCoord; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0f); TexCoord = vec2(aTexCoord.x, aTexCoord.y); } then, the matrix manipulated:
      ..... glm::mat4 projection = glm::perspective(glm::radians(fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f); ourShader.setMat4("projection", projection); .... glm::mat4 view = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp); ourShader.setMat4("view", view); .... model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f)); ourShader.setMat4("model", model);  
      So, some doubts:
      - Why use it like that?
      - Is it okay to manipulate the camera that way?
      -in this way, are not the vertex's positions that changes instead of the camera?
      - I need to pass MVP to all shaders of object in my scenes ?
       
      What it seems, is that the camera stands still and the scenery that changes...
      it's right?
       
       
      Thank you
       
    • By dpadam450
      Sampling a floating point texture where the alpha channel holds 4-bytes of packed data into the float. I don't know how to cast the raw memory to treat it as an integer so I can perform bit-shifting operations.

      int rgbValue = int(textureSample.w);//4 bytes of data packed as color
      // algorithm might not be correct and endianness might need switching.
      vec3 extractedData = vec3(  rgbValue & 0xFF000000,  (rgbValue << 8) & 0xFF000000, (rgbValue << 16) & 0xFF000000);
      extractedData /= 255.0f;
    • By Devashish Khandelwal
      While writing a simple renderer using OpenGL, I faced an issue with the glGetUniformLocation function. For some reason, the location is coming to be -1.
      Anyone has any idea .. what should I do?
  • Advertisement