Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Jedimace1

Pages: [1]
1
Graphics / sf::Image.LoadFromFile might be causing invalid pointers?
« on: February 25, 2010, 02:04:17 am »
Hello,

I'm getting this really weird problem in my SFML/OpenGL application. I've created my application, which should render a triangle in multiple colors and then a square with a texture on it. I used SFML's texture loading for my texture, but then I ran into this really weird problem. I'm sure it's this line specifically because I commented out everything else and it still happened. When I run my program, it beeps once about ever third of a second, and shows a bunch of stuff in the console, and then it crashes saying that the OpenGL buffer got overrun (even when I don't use OpenGL). Here's my code:

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main() {
sf::Window window(sf::VideoMode(800, 600), "Rendering", sf::Style::Close);

sf::Image image;

        //Problem line....
if(!image.LoadFromFile("Texture.png")) {
return 1;
}

GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.GetWidth(), image.GetHeight(),
0, GL_RGB, GL_UNSIGNED_BYTE, image.GetPixelsPtr());

glClearDepth(1.0f);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, 1.0f, 1.0f, 500.0f);

while (window.IsOpened()) {
sf::Event evnt;
while(window.GetEvent(evnt)) {
switch(evnt.Type) {
case sf::Event::Closed:
window.Close();
}

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glTranslatef(-1.5f,0.0f,-6.0f);

glBegin(GL_TRIANGLES);
glColor4f(0.0f,255.0f,255.0f,255.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);

glColor4f(255.0f,0.0f,255.0f,255.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);

glColor4f(255.0f,255.0f,0.0f,255.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();

glTranslatef(3.0f,0.0f,0.0f);
glRotatef(-25.0f, 0.0f, 1.0f, 0.0f);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureID);

glBegin(GL_QUADS);
glTexCoord2f(1.0f,1.0f);
glVertex3f( -1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f,0.0f);
glVertex3f(-1.0f,0.0f, 0.0f);
glTexCoord2f(1.0f,0.0f);
glVertex3f( 0.0f,0.0f, 0.0f);
glTexCoord2f(1.0f,1.0f);
glVertex3f( 0.0f,1.0f, 0.0f);
glEnd();

glDisable(GL_TEXTURE_2D);

window.Display();
}
}

return EXIT_SUCCESS;
}


And here's the error I get in a pop-up window asking me to break/continue the program.

Code: [Select]
Unhandled exception at 0x737a84b4 in OpenGL render.exe: 0xC0000005: Access violation reading location 0x003e9000.

I'm running a Radeon HD 5850 with SFML 1.5 prebuilt. Thanks for any help.

2
DotNet / .NET Interface
« on: February 23, 2010, 07:59:07 pm »
Hello,

I'm trying to use SFML in C#, because I'm porting some C++ code over for a level editor. I have a few questions about what it can do before I follow that path.

1- Can SFML be rendered in a Windows Form control? I am setting up the UI and serialization stuff in C# now, but will it be as simple as dragging in a render window for SFML into the tab control I have set up, or could I render into the tab control or a panel?

2- Does SFML allow me to use OpenGL with SFML in C#? I've seen some things like the Tao Framework. Can I just use the OpenGL functions from Tao in the SFML control, like I would with normal SFML?

3- Can I just port my C++ library to a C# library and use my own interfaces based on SFML?

I want the editor to be WYSIWYG, so I need to find a way to get identical rendering and audio on both C++ and C# with minimal effort, which is one reason I chose SFML. Thanks,

Pages: [1]