Not sure if anyone here might know, but im speaking with Laurent (sfml guy) about it.
Im trying to use an Image within a openGL program but it draws like this:
[img]http://i.imgur.com/nQmV5.png[/img]
the code I use is:
in main
[code]
titleScreen = TitleScreen(App);
...
//main loop
case menu:
{
titleScreen.Update();
App.SaveGLStates();
titleScreen.Draw();
App.RestoreGLStates();
break;
}
[/code]
title screen header
[code]
#ifndef TITLESCREEN_HPP_INCLUDED
#define TITLESCREEN_HPP_INCLUDED
#include <SFML/Graphics.hpp>
class TitleScreen
{
sf::RenderWindow *app;
sf::Texture titleImage;
public:
TitleScreen();
TitleScreen(sf::RenderWindow &App);
~TitleScreen();
void Draw();
void Update();
};
#endif // TITLESCREEN_HPP_INCLUDED
[/code]
titlescreen code
[code]
#include "TitleScreen.hpp"
TitleScreen::TitleScreen()
{
}
TitleScreen::TitleScreen(sf::RenderWindow &App)
{
app = &App;
titleImage.LoadFromFile("./data/Title.png");
}
TitleScreen::~TitleScreen() {}
void TitleScreen::Update()
{
}
void TitleScreen::Draw()
{
app->Draw(sf::Sprite(titleImage));
}
[/code]
At first it was doing it with any project with images (even a simple one that just loads 1 image) but now its just doing it with the openGL one
[QUOTE=Philly c;31944992]I really don't think that triangle fans are a good idea for this at all. Indices (indexes?) were practically made for terrain like this.[/QUOTE]
Triangle fans and indices aren't mutually exclusive, at least not in OpenGL. You put all the points in a vertex buffer and then make an index buffer that specifies the indices in the appropriate order for fans, with the restart value in between. The vertices shared by adjacent fans have their indices specified several times (once as part of each fan) but the actual coordinates are stored only once.
Is that not applicable in D3D?
I've learned the basic C++ stuff like, cout, if, arrays, but i'm not sure where to continue growing. What should I am for?
I'm learning C++ and I started with Visual Studio, but I've just installed Code::Blocks. When I make a project it asks me what compiler I should use, which is my best choice? GNU GCC is the default, would I be okay with that?
[QUOTE=Shounic;31953136]I've learned the basic C++ stuff like, cout, if, arrays, but i'm not sure where to continue growing. What should I am for?[/QUOTE]
cin, while loops, for loops and Classes? Functions maybe
[QUOTE=Elegwa;31953868]I'm learning C++ and I started with Visual Studio, but I've just installed Code::Blocks. When I make a project it asks me what compiler I should use, which is my best choice? GNU GCC is the default, would I be okay with that?
cin, while loops, for loops and Classes? Functions maybe[/QUOTE]
you want to use minGW, out of curiosity why is it that you dont want to us VS?
[QUOTE=Elegwa;31953868]I'm learning C++ and I started with Visual Studio, but I've just installed Code::Blocks. When I make a project it asks me what compiler I should use, which is my best choice? GNU GCC is the default, would I be okay with that?[/QUOTE]
GNU GCC is probably the only one you have installed (except for the Visual Studio compiler, maybe).
[QUOTE=Elegwa;31953868]I'm learning C++ and I started with Visual Studio, but I've just installed Code::Blocks. When I make a project it asks me what compiler I should use, which is my best choice? GNU GCC is the default, would I be okay with that? [/QUOTE]
GCC would be my first choice.
[QUOTE=Elegwa;31953868]I'm learning C++ and I started with Visual Studio, but I've just installed Code::Blocks. When I make a project it asks me what compiler I should use, which is my best choice? GNU GCC is the default, would I be okay with that?
cin, while loops, for loops and Classes? Functions maybe[/QUOTE]
well, functions'll have to happen before classes.
From what I've learned though, classes is where c++ starts to pick up a bit.
[QUOTE=moonage;31948255]ToString() is fine, where on earth did you hear it was bad[/QUOTE]
I guess it's mainly for Xbox development because the garbage collector is terrible on there.
[QUOTE=Mr. Smartass;31948340]Wohoo, got my problem fixed. I had to calculate every odd one, and then tell it how to position that particular vertecie.
[csharp]
private void SetUpIndices()
{
indices = new int[(terrainWidth - 1) * (terrainHeight - 1) * 6];
//sets the counter to default to 0.
int counter = 0;
for (int y = 0; y < terrainHeight - 1; y++)
{
for (int x = 0; x < terrainWidth - 1; x++)
{
// tells what the lower left, top left, lower right, and top right corners are, and where they are positioned.
int lowerLeft = x + y * terrainWidth;
int lowerRight = (x + 1) + y * terrainWidth;
int topLeft = x + (y + 1) * terrainWidth;
int topRight = (x + 1) + (y + 1) * terrainWidth;
//calculates what is defined as a slanted up cell, and what is not
bool slantUp = true;
if ((y % 2 == 0) && (x % 2 == 0))
slantUp = false;
if ((y % 2 == 1) && (x % 2 == 1))
slantUp = false;
//if the slant is up, tells it how it should calculate the tri's.
if (slantUp)
{
indices[counter++] = topLeft;
indices[counter++] = topRight;
indices[counter++] = lowerLeft;
indices[counter++] = topRight;
indices[counter++] = lowerRight;
indices[counter++] = lowerLeft;
}
// if the slant is NOT up, how it should calculate the tri's.
else
{
indices[counter++] = topLeft;
indices[counter++] = lowerRight;
indices[counter++] = lowerLeft;
indices[counter++] = topLeft;
indices[counter++] = topRight;
indices[counter++] = lowerRight;
}
}
}
}
[/csharp]
[editline]26th August 2011[/editline]
What would be the best method for storing map data? Currently I use grayscale heightmaps.[/QUOTE]
Listen buddy, don't use the postfix increment operator. It has side effects that most people don't know about, thus making your code do something that people probably don't think it does.
[QUOTE=Jookia;31954975]Listen buddy, don't use the postfix increment operator. It has side effects that most people don't know about, thus making your code do something that people probably don't think it does.[/QUOTE]
I use the post-increment operator all the time. What's wrong with it?
[QUOTE=jalb;31955105]I use the post-increment operator all the time. What's wrong with it?[/QUOTE]
Pretty much the only time you run into problems is if you try to do something retarded, like post-incrementing a value which is simultaneously being used elsewhere.
[QUOTE=ROBO_DONUT;31955210]Pretty much the only time you run into problems is if you try to do something retarded, like post-incrementing an value which is simultaneously being used elsewhere.[/QUOTE]
Isn't that the point of the operator though?
[csharp]array[x++] = 5;[/csharp]
instead of:
[csharp]array[x] = 5;
x += 1;[/csharp]
Edit: I could see cases where the post increment could screw you up, but in that case you should blame the coder. Not the operator.
[QUOTE=jalb;31955273]Isn't that the point of the operator though?
[csharp]array[x++] = 5;[/csharp]
instead of:
[csharp]array[x] = 5;
x += 1;[/csharp]
Edit: I could see cases where the post increment could screw you up, but in that case you should blame the coder. Not the operator.[/QUOTE]
I mean stuff like y= x++ + x;
The value of the second x is undefined, AFAIK.
[QUOTE=jalb;31955273]Isn't that the point of the operator though?
[csharp]array[x++] = 5;[/csharp]
instead of:
[csharp]array[x] = 5;
x += 1;[/csharp][/QUOTE]
Yes, that's the point. But some people don't realize that it actually does that and think that it increments first.
[QUOTE=ROBO_DONUT;31955367]I mean stuff like y= x++ + x;
The value of the second x is undefined, AFAIK.[/QUOTE]
Out of curiosity I decided to try that in C++ and C#.
[csharp]int x = 5;
int y = x++ + x;
Console.WriteLine(x);
Console.WriteLine(y);[/csharp]
C# resulted in x = 6, y = 11. C++ results in x = 6, y = 10. So there is definitely some argument there that this operator should be avoided. However, I'm curious what Jookia saw in Mr. Smartass's code that would be an issue.
[QUOTE=Jookia;31955484]Yes, that's the point. But some people don't realize that it actually does that and think that it increments first.[/QUOTE]
That goes back to what I said a moment ago. Blame the coder.
[QUOTE=jalb;31955504]So there is definitely some argument there that this operator should be avoided.[/QUOTE]
This wasn't my point at all.
Nobody writes "x++ + x" and it almost never makes sense to do so. The operator is perfectly fine in the usual case.
[QUOTE=ROBO_DONUT;31955538]This wasn't my point at all.
Nobody writes "x++ + x" and it almost never makes sense to do so. The operator is perfectly fine in the usual case.[/QUOTE]
Sorry! I knew I should of made myself a little more clear. I meant that it's an argument that it should be avoided in something confusing like that.
++x + x is undefined too, I think.
[QUOTE=Jookia;31955821]++x + x is undefined too, I think.[/QUOTE]
Yeah, overall the order of evaluation in statements and function calls is undefined.
A little offtopic note, today marks the first day in which my updated avatar is displayed on my end.
[QUOTE=Richy19;31953893]you want to use minGW, out of curiosity why is it that you dont want to us VS?[/QUOTE]
Because, I know my school uses CB and plus should I decided I want to move to linux, I'll already be familiar with at least something.
[QUOTE=Z_guy;31954069]GNU GCC is probably the only one you have installed (except for the Visual Studio compiler, maybe).[/QUOTE]
I apparently have quite a few!
[B]Edit:[/B] Going to dl the MinGW compiler then
[QUOTE=Elegwa;31957417]Because, I know my school uses CB and plus should I decided I want to move to linux, I'll already be familiar with at least something.
I apparently have quite a few!
[B]Edit:[/B] Going to dl the MinGW compiler then[/QUOTE]
Don't bother. MinGW is just the Windows port of GCC and its related tools. It stands for "Minimalist GNU for Windows".
If you already have GCC installed, there's no sense in downloading MinGW.
[QUOTE=Elegwa;31957417]I apparently have quite a few!
[B]Edit:[/B] Going to dl the MinGW compiler then[/QUOTE]
Code::Blocks lists all the compilers it supports and not just the ones you have installed. Also Code::Blocks comes with MinGW, so you don't need to install it separately.
[QUOTE=jalb;31955105]I use the post-increment operator all the time. What's wrong with it?[/QUOTE]
If you're using C++, someone can overload the increment operator which makes post-increment do an extra copy
I seriously don't see what I'm doing wrong here. I'm trying to make it so the camera can't rotate past 0f, but it just plain isn't stopping the rotation. I've gone it over and over again, and I just can't figure it out.
[csharp]
if (updownRot != 0f)
{
MouseState currentMouseState = Mouse.GetState();
if (currentMouseState != originalMouseState)
{
float xDifference = currentMouseState.X - originalMouseState.X;
float yDifference = currentMouseState.Y - originalMouseState.Y;
leftrightRot -= rotationSpeed * xDifference * amount;
updownRot -= rotationSpeed * yDifference * amount;
Mouse.SetPosition(device.Viewport.Width / 2, device.Viewport.Height / 2);
UpdateViewMatrix();
}
}
[/csharp]
Clamp it :v: Math.max(updownRot,0)
I'm new to python, I want to check if a variable is a letter and not a number, and if it is a letter it should print a message to the user.
I have this:
[code]bananas = input("Please enter how many bananas you want:")
if bananas == "a":
print ("A fucking number, dumbass.")
print bananas * 2
raw_input()[/code]
How would I do this?
[QUOTE=Map in a box;31963600]Clamp it :v: Math.max(updownRot,0)[/QUOTE]
Wow, I feel like a fucking retard now. I should probably go back, and look at all the math functions that C# has before I make dumb workarounds.
[QUOTE=C:\;31963787]I'm new to python, I want to check if a variable is a letter and not a number, and if it is a letter it should print a message to the user.
I have this:
[code]bananas = input("Please enter how many bananas you want:")
if bananas == "a":
print ("A fucking number, dumbass.")
print bananas * 2
raw_input()[/code]
How would I do this?[/QUOTE]
[URL]http://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-in-python[/URL] answers this perfectly
[code]
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
[/code]
Sorry, you need to Log In to post a reply to this thread.