file manipulation in C++ I can’t really help you with, but here’s a
crash course in C file manipulation.
filePointer = fopen("filename", "rb"); // in windows, you need to use "rb", but in most other OSes, you only need "r"
printf("something went wrong!1!1!1!1\n");
fgets(string, 512, filePointer);
just to explain that, you first declare a FILE *foo variable. It must
be a pointer to a FILE.
Then you use fopen to open the file. The first parameter is the
filename, the second is how to open it. “r” is “for reading”.
Then you check to see that it isn’t NULL. If it is, something went
wrong and we abort.
Then we declare a string that’s 512 chars long, and read 512 chars into
it. fgets reads chars into the first argument, until either the second
argument is reached (ie. 512 chars have been read) or the end of the
line is reached.
Then we close the file.
There are many more functions you can use, so look them up :)
Ok, I’ll post a demo sometimes tomorrow if not today…. However, I will
be writing it in C/C++, not Delphi, as I have little experience with
I’m not going to teaching myself, I’m just seeking for cutting-time
solution. I know the basic idea but my problem is reading the file. I
have no expirience with file manipulation in C++ and I know nothing
about BMP header. I’m writting my games in Delphi/OpenGL or C++/OpenGL
(Delphi is my prefered tool, becouse I’m writting Windows applications
with it). If you can make bmp to array converter I’ll be gratefull
I’ll post demo and level editor these days, I’m just seeking for good
enought web server
oh ok, now I understand your question.
Ok, first of all you need to load the pixel data of the file into
memory. Having an array like this is good enough.
unsigned char *data = new unsigned char[width*height*bpp]; // where bpp is bytes per pixel
then load the pixel data from the file into that array. Parsing files
depends from format to format. But since your loading BMP files, then
its easy (if no compression is applied). Its just a matter of copying.
All you need is to point the file pointer to the pixel data and do a
fread() or similar in a for loop. To make the pixel data consistent with
the RGB sequence instead of the BGR sequence just do this:
for (int i=0;i<height;i++)
int index = i*width*3;
data[index+j*3+2] = read8BitValue(filePtr, bytesRead);
data[index+j*3+1] = read8BitValue(filePtr, bytesRead);
data[index+j*3] = read8BitValue(filePtr, bytesRead);
Lets say for the sake of clarity that you are loading a 24-bit image,
then each 4 indicies of the array would represent a pixel. e.g. data
represents the blue, data green, data blue, etc…
To write all that to a file, all you need to is to fwrite() the data
array to the file. You will also need to store other information, like
width, height, depth, etc… in the file.
I hope I answered your question. I can post a whole demo on loading BMP
files if you want, but then it would be worth to make it a tutorial for
the general public.
I know how to include bitmaps and waves with VC++. But that is not what
I need. I meant is that I want to get the RGB values for all pixels in
the bitmap (bitmap is stored is this way: header and BGR values, BGR
means that it is stored Blue Green Red instead of Red Green Blue) and
put all RGB values for all pixels of all bitmaps into one file, called
In this way the game will be easy to port on Linux and graphics can be
Also I don’t know how to build bitmaps into resource of Delphi :( I
know how only if VCL is used but my game don’t use VCL
Do you mean you want to include the picture data inside the executable?
If you using delphi, I’m not sure how. But for Visual C++, all you have
to do is use resources. If you want more details on how do it, then let
me know :D
CG would be used in Gamez and presentations, media - LOTR stuff.
In CAD/CAM you dont need stunning graphix, what you need is realism
interms of physics and physical quantitites.
hmm, I’m not sure that cg would be used in CAD/CAM. There are more
appropriate solutions for the CAD/CAM industry, which aren’t appropriate
apex: you’re absolutely right and is the heart of all partnerships - to
reduce dev time.
working with a team, though, you lose control. be it design or approach.
there will be things that are generally wise to do and that everybody
should do and that’s fine. it’s things like wanting a certain feature
done a certain way and a fellow team member may have their own way of
designing or implementing that feature which may not go well.
but that’s why working with people you know* is key. if you know the
person, you can kind of tell how they’re going to develop it. better
yet, you can let that person know how you want it done. all leading to
what baldurk and davepermen are saying. communication and
sharing of resources. divide and conquer BUT act as one entity.
Well the debate of OGL Vs DirectX continues…
One of the major advantages of an OGL code is that its portablility &
genericity to any language. I can have one function defined in VC for
panning in 3D & the same will work good in Python! We just need to
handle the data types but the OGL calls more or less remain same.
Python has an implemented PyOpenGL library that implenets all the
openGl calls. Its much easy to handle things there.
Nextly Gaming is not the only industry where CG is Used. Are we
overlooking the Huge CAD/CAM industry?
I used a DX in some earler projects in my CAD firm but there was one
where we needed to implent Model Deformation through Graphics. The
challange was that the code needed to be workable on IRIX. PyOpenGL was
I think we all need to get out of the hole that Microsoft is digging by
forcing us to follow their standards. Just because lot of people use MS
standards does not make it better.
Besides that I personally find OGL is very easy to implement. One thing
where OpenGL *USED* to fall back was device interface; But OpenGL was
intended to be a purely a graphics API.
Anyways now with the advent of OpenML & OpenAL it has almost overcome
its limitations wrt DX as well!
Thanks donBerto : yes certainly working with a team is a good idea. Has
some advantages and disdvantages though.
One major advantage is that each team member can focus on a specific
aspect of the game which definitely reduces down development time.
from what I can see, normally you need someone to co-ordinate it. The
components have to be easily fitted together, and it’s that
co-ordination that I see failing and that’s what brings down community
projects. That and lack of time.
Sorry to be pessimistic, and I’m quite happy to join a group effort, but
perhaps we should learn from others mistakes?
Hmm :rolleyes: . When I read the help menu concerning the problem you
had, the help menu did not say anything about GLUT. But anyway
congratulations :) .
Hmm, I see where the problem is…
I tried a demo program using GLUT. When I initialize GLUT with
GLUT_RGBA and especially with GLUT_ALPHA,
it works. Unfortunately, I am not using GLUT, but Trolltechs Qt OpenGL
component. I have to look for an
equivalent option there.
Yes, I’m sure that I am rendering transparent objects, the color values
are all fine blended together.
I am using glReadBuffer(GL_BACK) to read from the back buffer (I’m
using double buffering).
There is no alpha buffer from where I can read the intermediate alpha
How are you rendering the screen? Are you sure you are rendering
Btw, read up on ‘glReadBuffer()’ to specify the buffer you want to read
what would be useful is to share components, means what ever gets
developed gets combined together. so everyone could do its own game, but
with combined resources.
and that way we could stay full platform independent, too. no mather
in response to baldurk’s post:
for the most part, I’m a very optimisitic kind of person - I’ll give
whatever it is I’m doing my best even when the majority has given up.
however, because of this I can come off as a bit naive. take
OpenCombat.org, a promising community that
failed miserably. myself and this person from canada by the handle of
zyklon were to only active developers out of 50+. our leader guy [the
person who organized] wasn’t very good at communication - and for good
reason. He came to a point in his life where he couldn’t afford to spend
much time on ‘hobbies’. the leader slowly dropped out of the picture and
the project unofficially became mine and zyklons. however, he, too, fell
out of the picture and then it was just me - the only one doing any real
work. I then ‘withdrew’, and have been working by myself. I’m sort of
discouraged working with people over distances now. in short, you’re
right and it’s sad.
in response to cyrax’s post:
that would be a great. I humored the idea of working with apex too. 2
heads are better than one. however, I think distance plays a big part.
there might be ideas or what have you that is easier shared in person. I
know teleconferencing can handle that now. which leads me to ask this:
how many of us in this community have worked or is working with distant
I read the values from the framebuffer with
All alpha values turn out to be 1.
well, that’s not the problem.. Do the colour values get read right?
Sorry, that’s not my problem. I know how to texture transparent objects,
but I want this alpha value in the framebuffer and I
have no idea how to do this. The alpha values in the framebuffer are
contstantly one after the rendering process.
if you look at the scene, make sure that the quads do have an alpha of
0.6. ie. see if you can see through them. If that’s OK, then it’s a
problem in the reading process.
well, whenever I see communities trying to create games, most of the
time it doesn’t work. It would be worth a try, but I think a lot of
people here are used to working on their own.
I’d be interested though, if it was possible.
I guess it all depends on how well you create your format, and just how
much you can gain by creating your own format. If your format is going
to end up almost exactly like MD3, there’s no point.
I would not really suggest making YOUR own format without taking a look
@ what other formats support.
For example you could strip down those parts of the MD3 model that
support the Shaders (I did because Riva TNT does not support it).
Creating ur own file format might just be a long process and often
would end up making the format itself very cumbersome.