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 - Zuzu_Typ

Pages: [1]
1
Window / Confusion with modern OpenGL
« on: July 26, 2016, 06:22:44 pm »
Dear community,

so is it possible to use modern OpenGL with SFML?

If so, how do you do it?

I don't seem to be able to get my code running, not creating a context with GLEW.

I even tried using the SFML-core attribute in the ContextSettings, but that didn't change anything.

So if I don't use my own GLEW context the program crashes at
Code: [Select]
glBindTexture(GL_TEXTURE_2D, 0);
Is it supposed to crash here or did I do a mistake somewhere?

I am using mostly modified code from learn-opengl.com .

Thank you for your time and help,
--Zuzu_Typ--

2
Window / Switching between Window Styles at runtime using GLEW
« on: July 17, 2016, 04:17:32 pm »
Hello Community,

I'm currently working on a small game engine in C++ using SFML.

Since SFML doesn't support modern OpenGL out of the box, I use my own GLEW context.

I know you could simply disable the compatibility mode in SFML, but as I'm fairly new to C++ and I always have issues with Cmake so that seems out of question.

So my problem is that when I try to switch between sf::Style::Default and sf::Style::Fullscreen, the window stops working and freezes.

I'll try to give you only the necessary code, which is hard, since the window runs in a separate thread than my main application.

Here is what the toggleFullscreen function looks like

Code: [Select]
// close the window
window.close();
exists = false;

fullscreen = (fullscreen) ? false : true; // enable fullscreen

// recreate the window
if (fullscreen) {
sf::VideoMode mode(fullWidth, fullHeight); // fullscreen resolution

window.create(mode, title, sf::Style::Fullscreen); // use fullscreen style
}
else {
sf::VideoMode mode(width, height); // default resolution

window.create(mode, title, sf::Style::Default); // use default style
}

exists = true; // declare the window as opened

glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK)
{
std::cout << "Failed to initialize GLEW" << std::endl;
Error::handle(1);
}

// Define the viewport dimensions
if (fullscreen) {
glViewport(0, 0, fullWidth, fullHeight);
}
else {
glViewport(0, 0, width, height);
}

// here I do OpenGL stuff, like creating shaders, buffers and prepare the texture that's supposed to be displayed

// note that I do not re use the already created shaders, since this part of the code is only temporary and new

// reload projection matrix
memory.projection = glm::perspective(45.0f, static_cast<GLfloat>(width) / static_cast<GLfloat>(height), 0.1f, 100.0f);

Is this sufficient code?

I also attached a GIF showing my output.

Thank you for your help and best regards,
--Zuzu_Typ--

Pages: [1]
anything