I'm working on a function which creates a pointers to an array of unsigned
ints based off a number read from a file. I then continue to read file names
from the file, convert the name to a char* and use it to load an texture
from some outside functions. My problem lies in the "for loop", the Code
goes as follows.
//I create the array of pointers, I'm using 2 just for the sake of an
example
MapTextures = new unsigned int[2];
//Start up a for loop
for(int I = 0; I < 2; I++)
{ //I then read the filename from the file.
LevelStream >> Cmd;
//Convert the string I read to a char*
Name = strdup (Cmd.c_str());
//Use the filename to load the coorisponding image into the first
element on the array
MapTextures[i] = LoadTextureWith Alpha(Name);
}
This is the way I'd like to do it, but for some reason it does'nt work and
for the life of me I can't figure out why. When the code executes it will
read both file names and convert them just fine, but it will only load one
texture. The following code I tried while I was troubleshooting and it works
perfectly.
LevelStream >> Cmd;
Name = strdup (Cmd.c_str());
MapTextures[0] = LoadTextureWith Alpha(Name);
LevelStream >> Cmd;
Name = strdup (Cmd.c_str());
MapTextures[1] = LoadTextureWith Alpha(Name);
This way is'nt preferable because it involves hardcoding a set amount, and I
really really want to know why the method involving the "for loop" will only
load the one texture. Given that this peice of code works it would, to me,
imply that the problem I'm having in the "for loop" lies in the fact that it
is a for loop and not the functions within.
Does it have something to do with the way a for loop is handled after
being compiled? Or am I just missing something obvious?
Thanks
Nick 10 2317
> This way is'nt preferable because it involves hardcoding a set amount, and
I really really want to know why the method involving the "for loop" will
only load the one texture. Given that this peice of code works it would, to me, imply that the problem I'm having in the "for loop" lies in the fact that
it is a for loop and not the functions within. Does it have something to do with the way a for loop is handled after being compiled? Or am I just missing something obvious?
Probably the error is in your LoadTextureWith Alpha function. Have you tried
using a debugger to find the problem ?
Niels Dybdahl Probably the error is in your LoadTextureWith Alpha function. Have you
tried using a debugger to find the problem ?
No Errors, Between Borland Builder 5 and Visual Studio 6 I'm not getting a
single error in the file loading aspect. Also, how would the loop affect the
Textre loading when the Consecutive hardcode version works fine?
Nick
"Nick L" <Fe********@mch si.com> wrote in message
news:ElVYc.2637 40$eM2.220413@a ttbi_s51... Probably the error is in your LoadTextureWith Alpha function. Have you tried using a debugger to find the problem ?
No Errors, Between Borland Builder 5 and Visual Studio 6 I'm not getting a single error in the file loading aspect. Also, how would the loop affect
the Textre loading when the Consecutive hardcode version works fine?
Could you post the minimal code that compiles and demonstrates your problem
?
> > Probably the error is in your LoadTextureWith Alpha function. Have you tried using a debugger to find the problem ? No Errors, Between Borland Builder 5 and Visual Studio 6 I'm not getting a single error in the file loading aspect.
But you stated earlier that the filenames were read and converted correctly,
so you call LoadTextureWith Alpha with the correct filename but it does not
load the correct texture. And you still state that there is no error in
LoadTextureWith Alpha ?
Also, how would the loop affect the Textre loading when the Consecutive hardcode version works fine?
As long as you have not found the reason for the error, you can not be sure
that the loop is causing the problem.
Niels Dybdahl Could you post the minimal code that compiles and demonstrates your
problem ?
That would be difficult. The function that loads in the texture is a
separate *.h file that contains 137 lines of code, all essential to loading
this image plus multiple that file and this file contain multiple opengl
references. If your up for a huge post, I'll do it, but I'm just trying to
save some aggravation of sifting through code. It's all a matter of, I get
no errors(or warning for that matter) when I compile it either way, one way
works and one doesn't. Kinda aggregating.
Nick But you stated earlier that the filenames were read and converted
correctly, so you call LoadTextureWith Alpha with the correct filename but it does not load the correct texture. And you still state that there is no error in LoadTextureWith Alpha ?
Yes, but I gave two peices of code, one in a loop and one that followed
the exact same code as that in the loop, but instead of looping twice I just
wrote it twice. Writing it twice works just fine, looping twice does'nt
As long as you have not found the reason for the error, you can not be
sure that the loop is causing the problem.
Not going to doubt that all, but all logic I can give to this right now
points to something about the loop. Why would looping twice not work, when
just writing it twice does. The actual reading and loading code never
changed, I just added a "for loop".
Nick
> Not going to doubt that all, but all logic I can give to this right now points to something about the loop. Why would looping twice not work, when just writing it twice does. The actual reading and loading code never changed, I just added a "for loop".
One possible cause could be that you have a dangling pointer or a buffer
overflow somewhere in your application. That could be located anywhere in
your application and the effect might only be visible under some
circumstances; f.ex when the code is formed as a loop.
If you do not want to use a debugger, you might try boundschecker or
something similar instead.
Niels Dybdahl
In article <86VYc.263646$e M2.249913@attbi _s51>,
"Nick L" <Fe********@mch si.com> wrote: I'm working on a function which creates a pointers to an array of unsigned ints based off a number read from a file. I then continue to read file names from the file, convert the name to a char* and use it to load an texture from some outside functions. My problem lies in the "for loop", the Code goes as follows.
//I create the array of pointers, I'm using 2 just for the sake of an example MapTextures = new unsigned int[2];
//Start up a for loop for(int I = 0; I < 2; I++) { //I then read the filename from the file. LevelStream >> Cmd; //Convert the string I read to a char* Name = strdup (Cmd.c_str()); //Use the filename to load the coorisponding image into the first element on the array MapTextures[i] = LoadTextureWith Alpha(Name); }
Your code looks like it leaks memory. Why are you using strdup?
const size_t limit = 2;
unsigned* MapTextures = new unsigned[limit];
for ( unsigned i = 0; i < limit; ++i ) {
string Cmd;
LevelStream >> Cmd;
MapTextures[i] = LoadTextureWith Alpha(Cmd.c_str ());
}
This is the way I'd like to do it, but for some reason it does'nt work and for the life of me I can't figure out why. When the code executes it will read both file names and convert them just fine, but it will only load one texture.
When you say it will only load one texture, do you mean that both
MapTextures elements contain the same value?
Nick L wrote: [redacted]
At the risk of sounding incredibly dumb, are you sure that (purely by
accident) you don't have a semicolon in the wrong place? I've done this
on many occasions.
I.e. if your loop is this:
for (int i = 0; i < N; ++i);
{
// do lots of stuff here
}
It won't work. I've done that. And every time I do it, I kick myself. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ian justice |
last post by:
Before i post actual code, as i need a speedyish reply.
Can i first ask if anyone knows off the top of their head, if there is
a likely obvious cause to the following problem.
For the moment i've reduced my form request to a simple text string
entry, instead of my desired optional parameters. As i have been stuck
with a single unfathomable glitch for over a year.
Basically, if i enter queries such as ;
"select * from table" "select * from...
|
by: Jonathan Driller |
last post by:
I am very new to this and would greatly appreciate some insight.
I am trying to learn Python by doing something useful; write a script
that will count and output my aggregated visits to my website. I have
a separate text file that holds the list of uri strings that I want to
count and then this code. The log is sampleLog.txt.
The problem is that it says all the preceding uris are 0 (they are
not) and only the last string actually is...
|
by: Mark Constant |
last post by:
I have a xslt file and it keeps giving me an EOF error when it reaches
the point
<xsl:for-each select="lc:Entertainment/lc:$Hardware">
and
<xsl:for-each select="lc:Entertainment/lc:$Hardware">
My xslt file looks like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
by: Arjen |
last post by:
Hello,
Here is my file input field:
<INPUT id="ImageFileUpload" style="WIDTH: 353px" type="file"
name="XmlFileUpload" runat="server" width="300" cssclass="NormalTextBox">
Here is my validator:
<asp:RequiredFieldValidator Display="Static" id="RequiredSrc" runat="server"
ControlToValidate="ImageFileUpload" CssClass="NormalRed" />
|
by: Raghu Raman |
last post by:
Hi ,
am storing the session id in my database when the user signs in.The
session_on start is firing nice & am doing my DB operations there &
quite working good.
But when the user closes the web browser(by clicking the x button)
suddenly , i need to delete the particular session id from my DB.But the
session_onend doesn't fire.
| |
by: lotus |
last post by:
HI All..
I'm realtively new to C#.
I have MainForm which includes Parent usercontol, and this parent
usercontrol also contains child usercontrol.
MainForm --> Parent usercontrol --> child usercontrol
Parent usercontol has one button to change the child usercontorl's
variable.
|
by: mrjoka |
last post by:
hi experts,
i'm developing a page in ASP but i'm doing also some javascript insode the page. i'm creating a frame and i want to loop this frame with a duplicateloop function so the form will be duplicate so many time, also i'm using a removeloop if the client want to remove the frame, in the html of the page i'm creating a table and i'm calling this loop, the problem now is that when i'm calling the removeloop it removes the frame but not the...
|
by: connectwithme |
last post by:
I am using the IE 6.x & Firefox 2.x
I am trying the event bubbling concept. Herez the code
<html>
<head>
<script>
function call_function(evt)
{ .........some_code_here.......}
</script>
|
by: matheussousuke |
last post by:
Hi, I have just uploaded a website to server, it's working fine, at least for one thing, if login to it on my computer (localhost) the login works fine, but if I do the same on webserver, it doesn't work, why?
I mean, I already checked user name and password on phpmyadmin from webserver, but if I use it, that doesn't works?
May someone help me, please?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |