Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
39 user(s) are online (31 user(s) are browsing Forums)

Members: 1
Guests: 38

serpi, more...
Support us!
Recent OS4 Files
OS4Depot.net



« 1 ... 37 38 39 (40)


Re: SDL2
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5529
@Capehill
What i was fear of , yep.. So , the only solution to do it as done in SDL1 version , as i understand , with that "Screen = SDL_SetVideoMode( 0, 0, 0, SDL_Flags );" , they just recreate window, without destorying context attached to it (or something of that sort ?). Is there anyway it can be done with SDL2 ?

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: SDL2
Quite a regular
Joined:
2007/7/14 20:30
From Lothric
Posts: 803
@kas1e

Please try resize-win branch.

   Report Go to top

Re: SDL2
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5529
@Capehill
Yeah ! It works ! Through found little issue. There is test code i use (just press "space" to switch bettwen resizable/non-resizable window as much as you want till cube rotated).

#include <SDL2/SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include <iostream>
using namespace std;

SDL_Window *glWindow;
SDL_GLContext glContext;

const 
int width 640;
const 
int height 480;

void drawCube(float xrffloat yrffloat zrf);

void init(){

    if ( 
SDL_Init(SDL_INIT_VIDEO) < ){ 
         
cout << "Unable to init SDL, error: " << SDL_GetError() << endl;
         exit(
1);
    } 

    
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER1);
    
SDL_GL_SetAttribute(SDL_GL_RED_SIZE5);
    
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE6);
    
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE5);

    
glWindow SDL_CreateWindow("Cube"SDL_WINDOWPOS_CENTEREDSDL_WINDOWPOS_CENTEREDwidthheightSDL_WINDOW_SHOWN SDL_WINDOW_OPENGL);
    
    
glContext SDL_GL_CreateContext(glWindow);
    
    if(
glWindow == NULL){
        exit(
1);
    }

    
// init opengl
    
    
glClearColor(0.0f0.0f0.0f0.0f); // black
    
glClearDepth(1.0);
    
glDepthFunc(GL_LESS);
    
glEnable(GL_DEPTH_TEST); // enable depth test
    
glShadeModel(GL_SMOOTH);
    
glMatrixMode(GL_PROJECTION);
    
glLoadIdentity();
    
gluPerspective(45.0f, (float) width / (float) height0.1f100.0f); // set 3d perspective
    
glMatrixMode(GL_MODELVIEW); // enable 3d mode

}



#ifdef __WIN32__
int WinMain(HINSTANCEHINSTANCELPSTRint){
#else
int main(int argcchar *argv[]){
#endif

    
init();

    
float xrf 0yrf 0zrf 0;

    
bool running true;
    
int a 0;

    while(
running){ 

    
xrf -= 0.5
    
yrf -= 0.5;
    
zrf -= 0.5;

    
drawCube(xrfyrfzrf); 

      
        
SDL_Event event;
      
        while ( 
SDL_PollEvent(&event) ){
            switch(
event.type){
                case 
SDL_QUIT:
                    
running false;
                break;

                case 
SDL_KEYDOWN:
                    switch(
event.key.keysym.sym){
                        case 
SDLK_ESCAPE:
                            
running false;
                            break;
                        case 
SDLK_SPACE:                            
                            if (
== 0) { 1SDL_SetWindowResizable(glWindow,SDL_TRUE); break;}; 
                            if (
== 1) { 0SDL_SetWindowResizable(glWindow,SDL_FALSE); break;};
                        break;
                    }
                break;
            } 
        }      

    }


    if(
glContext)
        
SDL_GL_DeleteContext(glContext);
        
glContext NULL;
    if(
glWindow)
        
SDL_DestroyWindow(glWindow);
        
glWindow NULL;

    
SDL_Quit();
    return 
0;
}


void drawCube(float xrffloat yrffloat zrf){
    
    
glClear(GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT);
    
    
glLoadIdentity();
    
glTranslatef(0.0f0.0f, -7.0f);
    
    
glRotatef(xrf1.0f0.0f0.0f);
    
glRotatef(yrf0.0f1.0f0.0f);
    
glRotatef(zrf0.0f0.0f1.0f);
    
    
glBegin(GL_QUADS);

    
glColor3f(0.0f1.0f0.0f);
    
glVertex3f1.0f1.0f, -1.0f);
    
glVertex3f(-1.0f1.0f, -1.0f);
    
glVertex3f(-1.0f1.0f,  1.0f);
    
glVertex3f1.0f1.0f,  1.0f);
    
    
glColor3f(1.0f0.5f0.0f);
    
glVertex3f1.0f, -1.0f,  1.0f);
    
glVertex3f(-1.0f, -1.0f,  1.0f);
    
glVertex3f(-1.0f, -1.0f, -1.0f);
    
glVertex3f1.0f, -1.0f, -1.0f);
    
    
glColor3f(1.0f0.0f0.0f);
    
glVertex3f1.0f,  1.0f1.0f);
    
glVertex3f(-1.0f,  1.0f1.0f);
    
glVertex3f(-1.0f, -1.0f1.0f);
    
glVertex3f1.0f, -1.0f1.0f);

    
glColor3f(1.0f,1.0f,0.0f);
    
glVertex3f1.0f, -1.0f, -1.0f);
    
glVertex3f(-1.0f, -1.0f, -1.0f);
    
glVertex3f(-1.0f,  1.0f, -1.0f);
    
glVertex3f1.0f,  1.0f, -1.0f);

    
glColor3f(0.0f,0.0f,1.0f);
    
glVertex3f(-1.0f,  1.0f,  1.0f);
    
glVertex3f(-1.0f,  1.0f, -1.0f);
    
glVertex3f(-1.0f, -1.0f, -1.0f);
    
glVertex3f(-1.0f, -1.0f,  1.0f);
    
    
glColor3f(1.0f,0.0f,1.0f);
    
glVertex3f1.0f,  1.0f, -1.0f);
    
glVertex3f1.0f,  1.0f,  1.0f);
    
glVertex3f1.0f, -1.0f,  1.0f);
    
glVertex3f1.0f, -1.0f, -1.0f);

    
glEnd();
    
    
glFlush();
    
SDL_GL_SwapWindow(glWindow);
    
}



Now issue is : if you run that example, then drag the window somewhere on workbench and then press "space" , then, together with adding resizable gadget window jump to the middle of the screen.

And that happens after eacht "2 presses" if you move window after each other to some new place : it then place to the place where was previous window.

And that "non remember of window position on screen" happens only after resizable gadget added. When you press "space" from the pure window (while non resizable gadget added), then it stays on the same position.

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: SDL2
Quite a regular
Joined:
2007/7/14 20:30
From Lothric
Posts: 803
@kas1e

I found a bug, IDCMP_CHANGEWINDOW event was not activated when window wasn't resizable.

   Report Go to top

Re: SDL2
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5529
@Capehill
Yeah, all fine now :) and that pretty nice feature should to say :) We can see of course fast close/opening of window but then that probabaly the only way we can do it on os4, and functionality are how it should be, so all good, thanks a bunch

Btw, have a question : should the window when we add/remove resize gadget jump inside of workbench borders ? I.e. i move for example window out of workbench for half of window, then press "space" in my test case (to enable/disable resize gadget), and then window jump inside of workbench borders.

That probabaly expected to be like this ?

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: SDL2
Quite a regular
Joined:
2007/7/14 20:30
From Lothric
Posts: 803
@kas1e

It depends on the WA_AutoAdjust tag, which is implicitly TRUE when window is opened with OpenWindowTags().

   Report Go to top


« 1 ... 37 38 39 (40)



[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project